Rough estimate, check with your seller: prices vary by shop and period.
Project goal
You will add a “virtual button” in parallel with the wall button of your garage door opener. From Home Assistant, the software that gathers all your connected devices, you send a pulse to an ESP32, a small electronic board with Wi-Fi; the board passes it to a relay, a switch it controls, which imitates a press of the button. A reed contact, a tiny switch triggered by a magnet, tells you whether the door is really closed: you end up with a “Garage door” entity that shows the door state, opens it and closes it.
Why build it
You open the door without a remote, you know whether it was left open, you get an alert after 15 minutes and you can close it remotely once you have checked by eye that nothing is in the way. This page gives the basic build; the full guide goes into the different opener brands. Because the relay only imitates a press of the existing button, the opener keeps applying its own safety features.
Useful terms for this project: ESP32 (small Wi-Fi board) · ESPHome (prepares the board’s program) · GPIO (the board’s pins) · OTA (update without a USB cable)
Prerequisites
- A garage opener with a dry-contact “button” input (check the manual: terminals are often labelled button, start, PP or BP).
- Home Assistant with ESPHome and 2.4 GHz Wi-Fi coverage in the garage.
- A multimeter to test the relay before wiring it in.
Diagrams
Parts list
This ESP32 board is the base for every project in the series. ESPHome also works with other ESP32 boards: the board-choice guide helps you compare them. Which ESP32 board to choose?
Suggested board
ESP32-C6-DevKitC-1
- Wi-Fi 6, Bluetooth 5, Zigbee and Thread (at hardware level)
- Supported by ESPHome (ESP-IDF framework)
- USB-C for flashing and power
Watch-outs
- 2.4 GHz Wi-Fi only
- Use a USB cable that carries data
Main components
| Item | Quantity | Role and precautions |
|---|---|---|
| ESP32-C6-DevKitC-1 | 1 | Control board (see the box above). |
| 1-channel 5 V relay module with optocoupler | 1 | Used only as a dry contact (COM + NO). Pick a module whose input accepts a 3.3 V signal; contacts are rated 250 V, but here only extra-low voltage is switched. |
| Wired magnetic (reed) door contact | 1 | Magnet on the door, contact on the rail or frame; reports “closed” when they face each other. |
| 2-core cable (0.5 mm²) | 2 to 10 m | Between the relay and the opener terminals, then to the reed contact. |
Small parts
| Item | Quantity | Role and precautions |
|---|---|---|
| USB-C data cable | 1 | For flashing and power. Charge-only cables do not carry data. |
| USB 5 V power supply (CE/UKCA-marked charger) | 1 | At least 1 A for the board alone; more if peripherals draw power from it. |
| Dupont jumper wires (male-female and female-female) | 1 | One mixed pack covers every prototype. |
| Breadboard | 1 | To test without soldering; replace with a soldered build if you need it permanent. |
| Low-voltage screw terminals or lever connectors | 1 | To connect sensor or dry-contact wires cleanly. |
| Heat-shrink tubing | 1 | Insulates solder joints and splices; avoid tape in a permanent build. |
| Vented plastic or 3D-printed enclosure | 1 | Protects the board; leave a cable gland and vents if the sensor measures air. |
Amazon links are affiliate links: the site may earn a commission at no extra cost to you.
Step-by-step build
Step 1. Prepare ESPHome and create the device
- In Home Assistant, open the ESPHome Device Builder add-on (see the tutorial “Install ESPHome in Home Assistant (Device Builder)”). ESPHome is the software that turns a simple settings file into the program for your ESP32 board, without you having to write any code.
- Open “Secrets” (top right): this file keeps your passwords apart, so you can share your configurations without revealing them. Check that wifi_ssid (the name of your Wi-Fi network), wifi_password, api_encryption_key (the key that encrypts the link with Home Assistant), ota_password (for updates without a cable) and ap_password (for the board’s fallback Wi-Fi network) exist, and add any missing line. A valid API key is a long 32-byte string encoded in base64, which you can generate with “openssl rand -base64 32”.
- Click “New device”, name it “porte-garage”, pick ESP32-C6, skip the flash for now, then replace the file content with the YAML from this page (“Edit”). YAML is a configuration file written in plain text: it describes, line by line, what the board must do.
What you should see: The file opens in the editor with syntax highlighting and no red underline.
Check: The “Validate” action (⋮ menu) answers “Configuration is valid”.
Step 2. Build the relay and contact on the breadboard
- First mount the relay, a switch that closes when the board tells it to, on the breadboard (a plate with holes that lets you wire without soldering), with the USB power unplugged. Connect its VCC input, which powers it, to the 5V pin of the board, GND to a GND pin and IN, the control wire, to GPIO18, one of the metal pins lined up along the edge of the board (GPIO means “general purpose input output”).
- Then connect the reed contact between GPIO19 and GND; its two wires are interchangeable, so no direction has to be respected.
- Do not connect the opener yet.
What you should see: The relay must not click when you plug USB in (only the red power LED lights).
Check: No loose wire touches another; the 5 V wire does not touch GPIO18 or GPIO19.
Step 3. Test the relay and contact with a multimeter
- Before touching the opener, test the relay on its own. In Home Assistant, open the “Garage door” entity and press “Open”: you should hear the relay click for half a second, which proves the order reached the board.
- Set the multimeter to continuity on COM and NO: it beeps only during the pulse.
- Bring the magnet near the reed contact: “Garage door closed” turns on; move it away and it turns off.
What you should see: The pulse lasts about 0.5 s and the relay releases by itself, even if you cut the Wi-Fi.
Check: If the relay stays on, flip “inverted” in the YAML (module is active-high).
Step 4. Flash the board and add it to Home Assistant
- Connect the board to your computer with the USB-C data cable: “flashing” means writing the program into the board’s memory, and this first write must be done over a cable. The board can already be wired or sitting on the breadboard, but any external peripheral with its own power supply must stay switched off.
- In ESPHome click “Install”, then “Plug into this computer” (Chrome or Edge over HTTPS) or “Manual download” and upload the file with ESPHome Web (web.esphome.io). If the port is missing, follow the flashing tutorial.
- After the reboot open Settings → Devices & services: the ESPHome device is discovered; click “Configure” and paste the API encryption key.
What you should see: The “Logs” show the Wi-Fi connection and then “Successfully connected to Home Assistant”.
Check: The device appears under Devices & services → ESPHome with its entities; later updates need no cable and go over Wi-Fi (this is OTA, “Over The Air”).
Step 5. Connect the relay to the opener’s “button” input
- Cut the power to the opener at the circuit breaker, the protective switch in your electrical panel, first: even though the build is low voltage, the opener itself runs on mains power. Then find the two terminals of the wall button in the manual.
- Wire COM and NO of the relay in parallel with those terminals, keeping the existing button.
- Mount the reed contact and magnet, restore power and test with the door clear, watching it.
What you should see: A pulse from Home Assistant starts the same cycle as the wall button; the state changes to open as soon as the door leaves the closed position.
Check: Also test stopping mid-travel and the opener’s obstacle detection.
ESPHome code (YAML)
YAML is a configuration file written in plain text: it tells ESPHome what the board must do. Paste this one into ESPHome after creating the device. It targets an ESP32-C6 board; values to personalise are marked with “CHANGE” comments.
esphome:
name: porte-garage
friendly_name: Garage door
esp32:
board: esp32-c6-devkitc-1 # XIAO ESP32C6: use board: seeed_xiao_esp32c6
framework:
type: esp-idf # required for ESP32-C6
logger: # serial logs, also visible over Wi-Fi
api:
encryption:
key: !secret api_encryption_key
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid # 2.4 GHz network only
password: !secret wifi_password
ap: # fallback hotspot if the Wi-Fi is unreachable
ssid: "porte-garage fallback"
password: !secret ap_password
captive_portal:
switch:
- platform: gpio
id: garage_relay
pin:
number: GPIO18 # relay IN pin
inverted: true # CHANGE: most opto-isolated relay boards trigger on LOW
restore_mode: ALWAYS_OFF # never leave the contact closed after a reboot
internal: true # hidden from Home Assistant: only the cover is exposed
on_turn_on:
- delay: 500ms # 0.5 s pulse = one press of the wall button
- switch.turn_off: garage_relay
binary_sensor:
- platform: gpio
id: garage_closed
name: "Garage door closed"
device_class: garage_door
pin:
number: GPIO19 # reed contact between this pin and GND
mode: INPUT_PULLUP
inverted: true # contact closed (magnet near) = door closed = ON
filters:
- delayed_on_off: 100ms # debounce
cover:
- platform: template
name: "Garage door"
device_class: garage
lambda: |-
return id(garage_closed).state ? COVER_CLOSED : COVER_OPEN;
open_action:
- if:
condition:
binary_sensor.is_on: garage_closed
then:
- switch.turn_on: garage_relay
close_action:
- if:
condition:
binary_sensor.is_off: garage_closed
then:
- switch.turn_on: garage_relay
stop_action:
- switch.turn_on: garage_relay # most openers stop on a new press while moving
sensor:
- platform: wifi_signal
name: "WiFi signal"
update_interval: 120s
entity_category: diagnostic
YAML comments are in English, as in the ESPHome documentation. This code has not been run on your hardware: use “Validate” before flashing and adjust pins and names.
Home Assistant integration
- The “Garage door” entity (garage type) appears with open, close and stop buttons; add it to a dashboard with a “Tile” card.
- Alert automation: “State” trigger on the entity, value “open” for 15 minutes, action: phone notification.
- Never automate opening on arrival without confirmation, and if you expose the door to a voice assistant, enable the passcode confirmation when offered.
Common problems and troubleshooting
| Symptom | Fix |
|---|---|
| The relay clicks when the board boots | Active-high module or unstable pin at boot: flip “inverted”, try another free GPIO or a module whose input supports 3.3 V. |
| The door does not react | The contact may be on the wrong pair of terminals (photocell power, for example). Check in the manual that they are the “button” terminals and test the relay’s continuity. |
| The state is inverted | The reed contact is normally open or closed depending on the model: change “inverted” on the binary_sensor. |
| The state flickers open/closed | Mount the magnet more firmly, bring it within a few millimetres of the contact and raise the delayed_on_off filter. |
FAQ
Can I open the door without touching the opener’s wiring?
Yes: a ready-made dry-contact Wi-Fi relay replaces the DIY build. The full guide compares these options and their limits.
Is it safe to control a door remotely?
Yes if the opener’s safety devices work and you only close with the door in view. This build replaces no safety device: it only presses the button.
What happens if Wi-Fi drops?
The remote and wall button keep working because the relay is in parallel. Only control through Home Assistant is unavailable.
Related tutorials
These step-by-step guides explain the gestures common to every project in the series.
- Install ESPHome in Home Assistant (Device Builder)Install the add-on, prepare your passwords (secrets) and create the first device
- Flash an ESP32 with ESPHome (USB, drivers, boot mode)First upload over USB, CP210x and CH340 drivers, boot mode
- ESP32 wiring basics: GPIO, 3.3 V and pull-upsWhich pins to avoid, 3.3 V versus 5 V, pull-up resistors and common ground
- ESPHome OTA updates: flash without a cableUpdate the board without a cable, OTA password and recovery if something goes wrong
Other ESP32 projects
- mmWave presence sensor (LD2410)
- Water leak detector
- BME280 + BH1750 weather station
- See all ESP32 projects
