Skip to content
cropped-image.webp

cropped-banner-promo-full-yellow.jpg

Connect with Us

  • Facebook
  • Twitter
  • Linkedin
  • VK
  • Youtube
  • Instagram
Primary Menu
  • Home
  • Blog
Light/Dark Button
Watch Video
  • Home
  • The Lab
  • ESP32 Smart Garage Door Opener (IoT)
  • The Lab

ESP32 Smart Garage Door Opener (IoT)

Friday February 19, 2026 (Last updated: February 20, 2026) 3 minutes read

Difficulty: Intermediate
Time Required: 2 hours
Cost: $15-20
ESP Board: ESP32

What You’ll Need

Component Cost Where to Buy
ESP32 Dev Board $5-8 Amazon
5V Relay Module $3-5 Amazon
Current Sensor (Optional) $3-5 Amazon
Jumper Wires $2 Amazon

Circuit Diagram

ESP32 Pin Component
5V Relay VCC
GND Relay GND
GPIO 26 Relay IN
GPIO 25 Button (for manual control)

The Complete Code

/*********************************************************************
 * ESP32 Smart Garage Door Opener
 * 
 * Control garage door via WiFi and Telegram
 * Hardware: ESP32, 5V Relay, Push Button
 *********************************************************************/

#include 
#include 
#include 

// ============== WIFI ==============
const char* wifi_ssid = "YOUR_WIFI";
const char* wifi_password = "YOUR_PASSWORD";

// ============== TELEGRAM ==============
#define BOT_TOKEN "YOUR_BOT_TOKEN"
#define CHAT_ID "YOUR_CHAT_ID"

WiFiClientSecure client;
UniversalTelegramBot bot(BOT_TOKEN, client);

// ============== PINS ==============
#define RELAY_PIN 26
#define BUTTON_PIN 25
#define LED_PIN 2

// ============== CONFIG ==============
unsigned long lastTrigger = 0;
const unsigned long DOOR_TIME = 1000;  // 1 second pulse

bool doorState = false;  // false = closed, true = open

void setup() {
  Serial.begin(115200);
  
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(LED_PIN, OUTPUT);
  
  digitalWrite(RELAY_PIN, HIGH);  // Relay OFF
  digitalWrite(LED_PIN, LOW);
  
  connectToWiFi();
  client.setCACert(TELEGRAM_CERTIFICATE_ROOT);
  
  Serial.println(F("Garage Door Opener Active!"));
}

void loop() {
  // Check manual button
  if (digitalRead(BUTTON_PIN) == LOW) {
    toggleDoor();
    delay(500);  // Debounce
  }
  
  // Check for Telegram commands
  handleTelegram();
  
  delay(100);
}

void toggleDoor() {
  unsigned long now = millis();
  if (now - lastTrigger < 5000) {
    return;  // Prevent rapid triggers
  }
  
  lastTrigger = now;
  
  Serial.println(F("Toggling door..."));
  
  // Pulse relay
  digitalWrite(RELAY_PIN, LOW);
  delay(DOOR_TIME);
  digitalWrite(RELAY_PIN, HIGH);
  
  // Flash LED
  for (int i = 0; i < 3; i++) {
    digitalWrite(LED_PIN, HIGH);
    delay(200);
    digitalWrite(LED_PIN, LOW);
    delay(200);
  }
  
  String status = doorState ? "CLOSED" : "OPEN";
  doorState = !doorState;
  
  bot.sendMessage(CHAT_ID, "Garage door is now " + status, "");
}

void handleTelegram() {
  int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
  
  for (int i = 0; i < numNewMessages; i++) {
    String chat_id = String(bot.messages[i].chat_id);
    String text = bot.messages[i].text;
    
    if (chat_id == CHAT_ID) {
      if (text == "/open" || text == "/close" || text == "/toggle") {
        toggleDoor();
        bot.sendMessage(chat_id, "Door command received!", "");
      } else if (text == "/status") {
        String status = doorState ? "OPEN" : "CLOSED";
        bot.sendMessage(chat_id, "Garage door is " + status, "");
      } else if (text == "/start") {
        bot.sendMessage(chat_id, "Garage Door Bot\n/open - Open door\n/close - Close door\n/status - Check status", "");
      }
    }
  }
}

void connectToWiFi() {
  WiFi.begin(wifi_ssid, wifi_password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }
  Serial.println(F(" Connected!"));
}

Official Documentation

  • Telegram Bot Library

Safety Warning

⚠️ Important: When controlling AC garage doors, ensure proper isolation between ESP32 and door wiring. Use an optocoupler for the relay control circuit.

About The Author

Friday

See author's posts

Post navigation

Previous: ESP8266 Motion Sensor Security System
Next: ESP32 WiFi LED Controller (RGB Strip)

Related Stories

  • The Lab

BeagleBone Black vs ESP32: Linux vs Bare-metal 2026

Friday March 11, 2026
  • The Lab

Teensy 4.1 vs ESP32: Speed and Performance 2026

Friday March 10, 2026
  • The Lab

ESP32 vs STM32H7: High-Performance Applications 2026

Friday March 9, 2026

Connect with Us

  • Facebook
  • Twitter
  • Linkedin
  • VK
  • Youtube
  • Instagram

Trending News

BeagleBone Black vs ESP32: Linux vs Bare-metal 2026 1
  • The Lab

BeagleBone Black vs ESP32: Linux vs Bare-metal 2026

Friday March 11, 2026
Teensy 4.1 vs ESP32: Speed and Performance 2026 2
  • The Lab

Teensy 4.1 vs ESP32: Speed and Performance 2026

Friday March 10, 2026
ESP32 vs STM32H7: High-Performance Applications 2026 3
  • The Lab

ESP32 vs STM32H7: High-Performance Applications 2026

Friday March 9, 2026
ESP32 vs Google Coral: AI on the Edge 2026 4
  • The Lab

ESP32 vs Google Coral: AI on the Edge 2026

Friday March 9, 2026
ESP32 vs ESP8266: Deep Sleep and Battery Life 2026 5
  • The Lab

ESP32 vs ESP8266: Deep Sleep and Battery Life 2026

Friday March 8, 2026

You May Have Missed

  • The Lab

BeagleBone Black vs ESP32: Linux vs Bare-metal 2026

Friday March 11, 2026
  • The Lab

Teensy 4.1 vs ESP32: Speed and Performance 2026

Friday March 10, 2026
  • The Lab

ESP32 vs STM32H7: High-Performance Applications 2026

Friday March 9, 2026
  • The Lab

ESP32 vs Google Coral: AI on the Edge 2026

Friday March 9, 2026
CoreEcom provides honest, research-backed reviews and essential guides. We filter the noise to help global consumers find quality products that deliver real value, ensuring every purchase is a smart investment.

Categories

Buyer's Manuals Deep Reviews Editor's Choice Latest News Setup Guides The Lab

Quick Links

  • About
  • Editorial Standards
  • Privacy
  • Impressum
  • Contact
  • Facebook
  • Twitter
  • Linkedin
  • VK
  • Youtube
  • Instagram
Copyright © Growthscout 2026 All rights reserved. | ReviewNews by AF themes.