The Secret Service Header in My Garage Door Opener Now Answers to an ESP32
Photo by Photo by Thorium on Unsplash on Unsplash
Garage door openers are weirdly analog machines wearing a plastic shell. The wall button is usually a low-voltage dry contact, the safety beam is a simple interlock, and the logic board has been doing reliable work for decades. That is exactly why I wanted my ESP32 to talk to the opener the same way a human does: press the button, watch the limit switches, and stay out of the motor’s business.
Why local beats another cloud bridge
A lot of garage gadgets work by pretending to be your phone. They bridge the manufacturer’s app to the opener, then bridge the manufacturer’s cloud to your phone. When the internet is down, the app is down. When the vendor changes its API, your automation is down. And when the opener is moving a 300-pound door, down is not a fun state.
My goal was narrower. I wanted Home Assistant to know whether the door was open or closed, and I wanted a local button I could trigger from my own network. No cloud account, no third-party server, no automatic closing while the cat is under the beam. The ESP32 would pulse the same terminals the wall console uses, and two magnetic switches on the rail would tell it the truth.
What is actually inside the wall console
I unplugged the opener first. That is not optional. The opener is tied to mains power, the rail is under spring tension, and the door itself can move when you least expect it. If you are not comfortable working around that, stop at the wall console and use a current sensor instead.
Inside my wall console there was a small PCB, a couple of tactile switches, an LED, and a four-conductor cable back to the opener. The two important wires landed on terminals labeled for the pushbutton. On this model, a momentary short across those terminals toggles the door. Some openers use separate open and close terminals, and some use a serial wall console that is not a simple dry contact. Check your manual and measure before you assume.
The logic board is the other half of the story. I found a four-pin header near the microcontroller with labels that looked like TX, RX, GND, and a 3.3V rail. That is a debug UART, not a public API. I treated it as read-only until I had a logic analyzer on it. The header can be useful for sniffing state messages, but it is not a safety-rated input. Do not send random bytes to an opener just because the pads are labeled nicely.
The parts list that kept me out of trouble
- ESP32-C3 or ESP32 DevKit board, powered from its own 5V supply
- Two PC817 optocouplers, or an optoisolated relay module rated for the wall console circuit
- 330 ohm resistors for the opto LED side
- Two magnetic reed switches and a magnet for open and closed limits
- Small 5V isolated DC-DC converter if you insist on sharing a supply
- Fuse holder and a 250mA fuse on the ESP32 supply
- Terminal blocks, 18 AWG wire, heat-shrink, and a project box
- USB isolator and a 3.3V USB-serial adapter for the UART sniffing step
- A small UPS or battery bank for the ESP32 if you want state reporting during outages
The important part is not the ESP32. It is the isolation. The opener’s low-voltage terminals can still be electrically noisy, and the logic board sits near mains. I used the optocoupler’s phototransistor side as a dry contact across the wall console terminals. The ESP32 only sees the LED side. If the opto fails short, the worst case is a stuck button, which is bad enough that I added a hardware pulse limit in firmware and a physical disconnect switch.
Wiring the button and the limits
For the button, connect one ESP32 GPIO through a 330 ohm resistor to the PC817 LED anode, and the LED cathode to ESP32 ground. On the output side, connect the phototransistor collector to one wall-console terminal and the emitter to the other. Pulse the GPIO for 300 to 400 milliseconds, then release. Do not hold it low. Do not tie it to a boot pin that glitches on reset.
For door state, I mounted one reed switch at the closed limit and one at the open limit. The magnet rides on the door. Each switch pulls a GPIO to ground when the door is at that end of travel. I used the normally open contacts and enabled internal pullups, then debounced in software for 200 milliseconds. A single tilt sensor can work, but limit switches are boring and boring is good when the door is heavy.
If your opener has a serial wall console instead of dry contacts, do not guess. Put a logic analyzer on the line and look for a known protocol before you connect anything. Some consoles send a stream of button codes and status bits. Others are proprietary. If you cannot identify it safely, use an external relay across a spare remote instead, or stick to read-only current sensing.
Firmware rules for a door that can hurt someone
The ESP32 firmware should be a state machine, not a vibe. I expose a local API through ESPHome, but the API only accepts a toggle request when the door is stationary and both limit switches agree. The physical wall button always wins. There is no auto-close schedule unless the safety beam is clear and the request came from a human in the last ten seconds. I also added a maximum runtime timer: if the door is not at a limit after 30 seconds, the firmware reports a fault and refuses further commands until I clear it.
The UART header stayed read-only. I used it to log status messages to a spare serial port, not to inject commands. That gave me useful context, such as when the opener thought the beam was obstructed, without turning the ESP32 into an unverified remote control for a motor.
Failure modes that actually matter
A stuck optocoupler can hold the button line active. A failed reed switch can report closed when the door is open. A power glitch can reboot the ESP32 mid-pulse. A nearby lightning strike can take out the opener board and the ESP32 together. A cloud-free setup does not make any of that safe by itself; the physical button, the safety beam, and the opener’s own force limits still do the real work.
That is why I fused the ESP32 supply, used an opto instead of a bare transistor, kept the wall console connected, and labeled the disconnect switch. The local API is a convenience. The door is still a machine that can crush a bicycle helmet flat. Treat the serial port as a clue, the dry contact as the control point, and the limit switches as the only state you trust.