Projects / Smart garage door controller

Smart garage door controller

Intermediate2 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. ESP32

    Test the reed switch

    Print the state.

  2. ESP32ON

    Test the relay

    Click it from the sketch.

  3. ESP32

    Find the button terminals

    Low voltage only.

  4. ESP32ON

    Connect the relay across them

    Dry contact.

  5. ESP32

    Add the web page

    State and the press link.

  6. ESP32

    Set a long token

    Random letters and numbers.

  7. ESP32

    Test with the door clear

    Watch it all the way.

In short

How do you build a smart garage door controller?

An ESP32 triggers a garage door's button and knows if it is open or closed. You need ESP32 DevKit V1, Relay module 1-channel 12 V, Door reed switch MC-38, 5 V 2 A USB adapter and 12 V 2 A DC adapter. It takes 7 steps and about 120 minutes.

Level
Intermediate
Time
About 120 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Relay INESP32 GPIO26Button press
Relay VCC and GND12 V adapterRelay supply
Relay COM and NOAcross the opener's wall-button terminalsDry contact, like pressing the button
Reed switchESP32 GPIO27 and GNDDoor closed sensor
ESP32 VIN and GND5 V adapterPower the board
All groundsJoinedCommon ground (not to the opener's terminals)

Code

The relay contacts only mimic a finger on the wall button, so the opener's own electronics, including its safety beam and force limits, stay in charge, and nothing is bypassed. Wire the relay across the two low-voltage terminals of the wall button, which carry only a few volts, never to the mains side of the opener, and if you are not sure, ask an electrician or the opener's maker. Never defeat or move the photo-eye safety sensors; a garage door can injure or kill, so only press the button when you can see that the way is clear, and keep children away from the controls. The reed switch and magnet tell you whether the door is closed. The press needs a long secret token in the address, but the page is not encrypted, so keep it on your home network only and never forward its port to the internet; if you want to open the door from outside, use a VPN to your home. Put your own Wi-Fi details in the placeholders and keep them private. A garage door controller is a security weak point; if the Wi-Fi fails, the wall button and the remote must still work.

Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Garage door controller: a relay presses the opener button, a reed switch reports the door state. Board: ESP32 Dev Module.
#include <WiFi.h>
#include <WebServer.h>
const char* SSID = "YOUR_WIFI_NAME";
const char* PASS = "YOUR_WIFI_PASSWORD";
const char* TOKEN = "CHANGE_THIS_LONG_RANDOM_TOKEN";   // required in the web address to press the button
const int RELAY = 26, REED = 27;
WebServer server(80);
unsigned long openedAt = 0;
bool wasClosed = true;
bool closed() { return digitalRead(REED) == LOW; }     // magnet near the reed means closed
void handle() {
  String state = closed() ? "closed" : "OPEN";
  server.send(200, "text/plain", String("Door is ") + state);
}
void handlePress() {
  if (server.arg("t") != TOKEN) { server.send(403, "text/plain", "No"); return; }
  digitalWrite(RELAY, HIGH); delay(500); digitalWrite(RELAY, LOW);   // one short press, like a finger
  server.send(200, "text/plain", "Pressed");
}
void setup() {
  pinMode(RELAY, OUTPUT); digitalWrite(RELAY, LOW);
  pinMode(REED, INPUT_PULLUP);
  WiFi.begin(SSID, PASS);
  while (WiFi.status() != WL_CONNECTED) delay(300);
  server.on("/", handle);
  server.on("/press", handlePress);
  server.begin();
}
void loop() {
  server.handleClient();
  bool c = closed();
  if (!c && wasClosed) openedAt = millis();
  wasClosed = c;
  if (!c && millis() - openedAt > 600000UL) { /* door open ten minutes: add a notification here */ openedAt = millis(); }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
PageShows closed or OPEN
Press with the right tokenDoor moves
Wrong tokenRefused
Safety sensorsStill stop the door

If it does not work

Relay clicks but the door ignores it

Check the terminals and the press time.

Wrong state

Flip the reed logic or move the magnet.

No page

Check Wi-Fi details and the IP address.

Door moves unexpectedly

Remove the controller and check the opener.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the smart garage door controller?

ESP32 DevKit V1, Relay module 1-channel 12 V, Door reed switch MC-38, 5 V 2 A USB adapter and 12 V 2 A DC adapter.

How long does the smart garage door controller take to build?

About 120 minutes for a intermediate maker, in 7 steps.

How do I know the smart garage door controller works?

Page: Shows closed or OPEN. Press with the right token: Door moves. Wrong token: Refused.

Relay clicks but the door ignores it: what should I check?

Check the terminals and the press time.

Wrong state: what should I check?

Flip the reed logic or move the magnet.

No page: what should I check?

Check Wi-Fi details and the IP address.

Door moves unexpectedly: what should I check?

Remove the controller and check the opener.