Skip to content
Buy 10+ on select items — save 10% auto-applied
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Skip to main content

ESP32 Reed Switch Relay: Remote Garage Door Control | ShillehTek

May 19, 2026 28 views

ESP32 Reed Switch Relay: Remote Garage Door Control | ShillehTek
Project

Build an ESP32 garage door controller with a reed switch and relay for remote open/close and real-time door status alerts over Wi-Fi, using ShillehTek parts.

2 hr Intermediate3 parts

Project Overview

ESP32 + reed switch + relay garage door control: An ESP32 reads a magnetic reed switch to detect whether your garage door is open or closed, then pulses a 1-channel relay to trigger the wall-button circuit so you can open, close, and check status over Wi-Fi.

Add a Telegram bot (as shown below) and you can control the door from anywhere with simple commands.

  • Time: ~2 hours
  • Skill level: Intermediate
  • What you will build: An ESP32 reporting door state and triggering the opener on demand over Wi-Fi.
ESP32 Wi-Fi garage door opener build using a relay module and a magnetic reed switch
ESP32 + reed switch + relay for remote garage control.

Parts List

From ShillehTek

External

  • Magnetic reed switch (door-sensor style) - detects open/closed state.
  • 5V USB power supply - powers the ESP32 and relay module.
  • 2 wires to splice into your garage opener’s manual button leads (low-voltage) - connects to relay COM and NO.

Safety: Splice ONLY into the low-voltage button leads (the wires running from the opener to the wall-mounted button). Never wire mains AC through this relay. If unsure, stop and consult an electrician.

Step-by-Step Guide

Step 1 - Mount the Reed Switch

Goal: Install the sensor so the ESP32 can detect when the door is open or closed.

What to do: Mount the reed switch on the door frame and the magnet on the moving door so they align when the door is closed.

Magnetic reed switch mounted on a garage door frame with magnet on the door
Closed when aligned, open when separated.

Expected result: When the door moves away from the frame, the reed switch changes state.

Step 2 - Wire the ESP32, Reed Switch, and Relay

Goal: Connect the door sensor to a GPIO input and the relay module to a GPIO output.

What to do: Make the following connections.

ESP32 wired to a magnetic reed switch on GPIO 13 and a 5V relay module on GPIO 27
Reed switch to GPIO 13 with internal pull-up; relay IN to GPIO 27.
  • Reed switch one leg to GPIO 13, other leg to GND (use INPUT_PULLUP)
  • Relay VCC to 5V, GND to GND, IN to GPIO 27
  • Relay COM and NO to the two manual-button leads on the opener

Expected result: The ESP32 can read door state on GPIO 13, and GPIO 27 can activate the relay to simulate a button press.

Step 3 - Upload the Sketch (Telegram Trigger)

Goal: Connect the ESP32 to Wi-Fi, report door state changes, and trigger the relay from Telegram commands.

What to do: Upload the code below, then set your Wi-Fi credentials and Telegram bot values (SSID, PASS, TOKEN, CHAT).

ESP32 garage door controller enclosure mounted near the garage door opener with relay and wiring
Mounted near the opener for short wire runs.

Code:

#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>

const char* SSID="WIFI", *PASS="PWD", *TOKEN="BOT", *CHAT="CHAT";
const int REED=13, RELAY=27;
WiFiClientSecure client;
UniversalTelegramBot bot(TOKEN, client);
bool lastDoor = HIGH;

void setup() {
  pinMode(REED, INPUT_PULLUP); pinMode(RELAY, OUTPUT);
  WiFi.begin(SSID, PASS);
  while (WiFi.status() != WL_CONNECTED) delay(500);
  client.setCACert(TELEGRAM_CERTIFICATE_ROOT);
}

void trigger() { digitalWrite(RELAY, HIGH); delay(500); digitalWrite(RELAY, LOW); }

void loop() {
  bool door = digitalRead(REED);
  if (door != lastDoor) {
    bot.sendMessage(CHAT, door == HIGH ? "🚪 Garage opened" : "🚪 Garage closed");
    lastDoor = door;
  }
  int n = bot.getUpdates(bot.last_message_received + 1);
  for (int i = 0; i < n; i++) {
    if (bot.messages[i].text == "/open" || bot.messages[i].text == "/close") trigger();
  }
  delay(1000);
}

Expected result: You receive a message when the door opens or closes, and the relay triggers when you send /open or /close.

Step 4 - Control It from Telegram

Goal: Verify remote control and status monitoring.

What to do: Send /open or /close to your bot and watch the door respond. Confirm you also get state change messages as the reed switch opens and closes.

Telegram bot chat showing /open and /close commands for an ESP32 garage door controller
Send /open or /close from anywhere.
Garage door moving after an ESP32 relay trigger with door status monitoring
Remote trigger plus real-time door state.

Expected result: Commands trigger the opener and door status updates reflect open/closed state.

Step 5 - Where to Take It Next

Goal: Identify safe, logical feature expansions for this same hardware pattern.

What to do: Consider these extensions.

  • Add HC-SR04 to measure car presence (or use the reed-switch trick on a second door)
  • Auto-close after N minutes of being open
  • Stream to Home Assistant via MQTT
  • Snapshot with ESP32-CAM on every door event

Expected result: You have a clear roadmap for expanding the project without changing the core wiring approach.

Conclusion

This build uses an ESP32, a magnetic reed switch, and a 1-channel relay module to monitor your garage door state and trigger the opener remotely over Wi-Fi. You get open/close alerts and simple remote control without needing a garage-specific app or subscription.

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.