
We’ve all been there. You’re ten minutes into your morning commute, sipping your lukewarm coffee, and suddenly a cold sweat washes over you: Did I close the garage door? You try to visualize pressing the button, but you can’t remember. Is your prized collection of half-finished projects and rusty drill bits currently exposed to the neighborhood?
Instead of turning around and being late for work, let’s fix this permanently. We’re going to build an ESP32 Smart Garage Door Controller. It uses a relay to act like a virtual finger pressing your wall button, and a magnetic reed switch to definitively tell you if the door is actually closed. No more guessing, no more paranoia, and absolutely no more turning the car around.
Most garage door openers have two terminals on the back where the wall-mounted button connects. If you short these two terminals together with a piece of wire, the door opens or closes. That’s exactly what our relay will do.
When your code pulls GPIO26 HIGH for half a second, the relay clicks, the terminals short, and the door moves. Magic.
Knowing you can open the door is great, but knowing if it’s actually closed is the real goal here. That’s where the magnetic reed switch comes in.
Mount one half of the switch on the garage frame and the magnet half on the door itself.
In your code, set GPIO27 to INPUT_PULLUP. When the door is closed, the magnet pulls the switch shut, connecting GPIO27 to GND (reading LOW). When the door opens, the switch breaks, and the internal pull-up resistor pulls GPIO27 HIGH. Now you know for sure if your tools are safe!
Tie this into Home Assistant or a custom web dashboard, and you can officially stop worrying during your morning commute.