Skip to content

mrahmadt/ESPHome-Control-Outdoor-Lock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ESPHome Gate Door Unlock (12V AC Electric Lock)

This project lets you remotely unlock your outdoor gate using ESPHome and Home Assistant.
It also allows you to trigger actions (like turning on lights) when the door is opened.

Rim Lock

⚠️ Important Warnings

  • Check your lock type first

    • This guide is for 12V AC locks
    • If your lock is 12V DC, wiring is different
  • Do NOT power the lock for more than ~2 seconds

    • Continuous power will damage the lock
  • Fail-safe behavior

    • Make sure your relay is configured to stay OFF on boot
    • Otherwise the lock may stay powered and burn

🧰 Components Required

  • ESP8266 (ESP-01 or similar)
  • 1-channel relay module (5V, supports external trigger)
  • 220V AC → 12V AC transformer (for lock)
  • 5V power supply (for ESP + relay)
  • Electric door lock (12V AC)
  • Wires

I used this ESP board with built in relay module ESP board with built in relay module


⚡ Power Setup

You will use two separate power sources:

  1. 12V AC → for the lock
  2. 5V DC → for ESP + relay module

⚠️ Do NOT mix them


🔌 Wiring Overview

1. ESP → Relay

ESP Pin Relay
GPIO0 IN
VCC 5V
GND GND

2. Relay → Lock (12V AC)

The relay works like a switch to allow current to flow to the lock.

Wiring Logic:

  • One wire from transformer goes directly to lock
  • The other wire goes through the relay (COM → NO)

🔧 Wiring Diagram

    220V AC
       │
┌───────────────┐
│  Transformer  │  (220V → 12V AC)
└───────────────┘
│       │
│       │
│       └───────────────┐
│                       │
│                    [ LOCK ]
│                       │
│                       │
│               ┌───────────┐
└──────────────▶│   COM     │
│   RELAY   │
│   NO      │◀─────── back to transformer
└───────────┘
            220V AC
               │
               │
       ┌────────────────┐
       │  Transformer   │
       │  220V → 12V AC │
       └────────────────┘
            │      │
            │      │
            │      │
            │      └───────────────┐
            │                      │
            │                  ┌─────────┐
            │                  │  LOCK   │
            │                  │ (12V AC)│
            │                  └─────────┘
            │                      │
            │                      │
            │               ┌───────────┐
            └──────────────▶│   COM     │
                            │   RELAY   │
                            │           │
            ┌──────────────▶│   NO      │
            │               └───────────┘
            │
            └───────────────────────────── back to transformer


    ESP8266                Relay Module
  ┌──────────┐          ┌─────────────┐
  │          │          │             │
  │  GPIO0 ───────────▶│ IN          │
  │          │          │             │
  │  VCC  ───────────▶ │ VCC (5V)    │
  │          │          │             │
  │  GND  ───────────▶ │ GND         │
  │          │          │             │
  └──────────┘          └─────────────┘

🧠 How It Works

  1. ESP sends signal → relay turns ON
  2. Relay closes circuit → 12V AC reaches lock
  3. Lock opens
  4. After ~200ms → relay turns OFF
  5. Lock stops receiving power

🔐 Safety Logic (Handled in ESPHome)

  • Lock is only triggered briefly (~200ms)
  • Cooldown prevents repeated triggers
  • Relay is always OFF on boot

🏠 Home Assistant Integration

  • You get a button: "Unlock Door"
  • Can be used in:
    • automations
    • mobile app
    • dashboards

Example use:

  • Unlock door
  • Turn on front light
  • Send notification

💡 Tips

  • Use good quality relay (cheap ones may fail)
  • Keep wiring clean and insulated
  • Test with short pulses first
  • If lock behaves weird → check AC vs DC

🚀 Next Ideas

  • Add door sensor (open/closed)
  • Auto light on open
  • Camera snapshot on unlock
  • Add keypad or RFID

📄 Notes

  • ESPHome YAML is provided separately in this repo
  • Adjust GPIO pin if needed
  • ESP-01 may require proper flashing setup

📜 License

Free to use and modify

About

Remote ESPHome-based gate unlock system using an ESP relay module and 12V AC electric lock, with safe pulse control and Home Assistant integration.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors