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.
-
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
- 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
You will use two separate power sources:
- 12V AC → for the lock
- 5V DC → for ESP + relay module
| ESP Pin | Relay |
|---|---|
| GPIO0 | IN |
| VCC | 5V |
| GND | GND |
The relay works like a switch to allow current to flow to the lock.
- One wire from transformer goes directly to lock
- The other wire goes through the relay (COM → NO)
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 │
│ │ │ │
└──────────┘ └─────────────┘
- ESP sends signal → relay turns ON
- Relay closes circuit → 12V AC reaches lock
- Lock opens
- After ~200ms → relay turns OFF
- Lock stops receiving power
- Lock is only triggered briefly (~200ms)
- Cooldown prevents repeated triggers
- Relay is always OFF on boot
- You get a button: "Unlock Door"
- Can be used in:
- automations
- mobile app
- dashboards
Example use:
- Unlock door
- Turn on front light
- Send notification
- 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
- Add door sensor (open/closed)
- Auto light on open
- Camera snapshot on unlock
- Add keypad or RFID
- ESPHome YAML is provided separately in this repo
- Adjust GPIO pin if needed
- ESP-01 may require proper flashing setup
Free to use and modify