A smart garage door opener with Telegram and ESP8266 gives you complete control over your garage from anywhere in the world using a simple Telegram bot. This project is particularly valuable in Indian residential complexes and villas where manual gate operation is inconvenient — imagine opening your garage from your car without stepping out in the rain or heat. The entire build costs under ₹600 and integrates with any existing garage door mechanism.
Table of Contents
- How the System Works
- Required Components
- Wiring and Circuit
- Setting Up the Telegram Bot
- Complete Arduino Code
- Security Features
- Advanced: Adding a Camera and Status Sensor
- Frequently Asked Questions
How the System Works
The system is elegantly simple. An ESP8266 (NodeMCU) connects to your home WiFi. A Telegram bot receives commands from your phone and triggers a relay that momentarily closes the garage door’s control circuit — exactly mimicking a button press on the physical wall switch. A magnetic reed switch monitors the door’s open/closed state and sends status updates.
The Telegram interface is ideal for Indian users because WhatsApp doesn’t support bot interactions the same way, and Telegram is free, fast, and works over even slow 2G/3G connections — useful when you’re at a gate with poor signal.
Required Components
- NodeMCU ESP8266 (any version: v1, v2, or v3)
- 5V single-channel relay module
- Magnetic reed switch / door sensor
- 5V power supply (or USB mobile charger)
- 2-core insulated wire (for relay to garage door connection)
- Jumper wires and project box
Total cost: ₹400–₹600. Commercial smart garage openers cost ₹4,000–₹15,000 in India.
Wiring and Circuit
NodeMCU ESP8266 Connections:
Relay Module:
D1 (GPIO5) → IN (relay signal)
3.3V or 5V → VCC
GND → GND
Relay NO/COM terminals → Garage door button wires
(Connect in PARALLEL with existing wall button)
Reed Switch (Door Sensor):
D2 (GPIO4) → Reed switch terminal
GND → Other reed switch terminal
// Enable internal pull-up in code
Power:
VIN (5V) → USB 5V charger
GND → GND
Garage Door Integration:
- Identify the two wires going to your wall-mounted
push button (usually in garage/car porch wall)
- Connect relay COM and NO in parallel with those two wires
- When relay closes, it acts as a button press
Setting Up the Telegram Bot
- Open Telegram and search for @BotFather
- Type
/newbotand follow the prompts to name your bot - Copy the API token (looks like:
123456789:ABCdefGHIjklMNOpqrSTUvwxYZ) - Find your Telegram Chat ID by messaging @userinfobot
- Note both values — you’ll need them in the code
You can also create a Telegram group and add your family members to share garage access. The bot will respond to everyone in the group.
Complete Arduino Code
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>
// WiFi credentials
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASS";
// Telegram Bot
#define BOT_TOKEN "YOUR_BOT_TOKEN"
#define CHAT_ID "YOUR_CHAT_ID" // Your personal chat ID
#define RELAY_PIN D1
#define DOOR_SENSOR D2
X509List cert(TELEGRAM_CERTIFICATE_ROOT);
WiFiClientSecure client;
UniversalTelegramBot bot(BOT_TOKEN, client);
bool doorOpen = false;
unsigned long lastTimeBotRan = 0;
const int botRequestDelay = 1000;
void triggerGarage() {
digitalWrite(RELAY_PIN, LOW); // Activate relay
delay(500);
digitalWrite(RELAY_PIN, HIGH); // Deactivate relay
}
void handleMessages(int numNewMessages) {
for (int i = 0; i botRequestDelay) {
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
while (numNewMessages) {
handleMessages(numNewMessages);
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
}
lastTimeBotRan = millis();
// Monitor door state changes
bool currentState = digitalRead(DOOR_SENSOR) == LOW;
if (currentState != doorOpen) {
doorOpen = currentState;
bot.sendMessage(CHAT_ID,
"Garage door " + String(doorOpen ? "OPENED" : "CLOSED"), "");
}
}
}
Security Features
Security is paramount for a garage opener. Implement these measures:
Whitelist Chat IDs
Store authorised Chat IDs in an array. Only these users can trigger the garage. Add family members by noting their Telegram Chat IDs.
String authorisedUsers[] = {
"123456789", // You
"987654321", // Spouse
"555555555" // Security guard
};
Auto-Close Timer
If the garage door has been open for more than 30 minutes, automatically trigger it to close and send an alert. This prevents accidentally leaving the garage open overnight — a common security concern in Indian neighbourhoods.
Usage Log
Log every open/close event with timestamp to EEPROM or an online spreadsheet via Google Sheets API. Useful for security audits.
Night Mode Alert
Send an urgent alert if the garage opens between 11 PM and 6 AM — potential security breach indication.
Advanced: Adding a Camera and Status Sensor
Enhance your garage opener with visual monitoring:
ESP32-CAM Integration
Add an ESP32-CAM module pointed at the garage entrance. When the garage opens, it automatically captures and sends a photo to your Telegram chat — you can visually verify who opened the garage.
Motion Sensor Alert
Add a PIR motion sensor inside the garage. If motion is detected when the garage is supposed to be empty, send an immediate Telegram alert — could indicate an intruder or a pet trapped inside.
Vehicle Detection
Use an ultrasonic sensor (HC-SR04) to detect whether a car is present in the garage. Combined with the door sensor, this tells you definitively whether the car is home — useful for family coordination in Indian joint households.
Frequently Asked Questions
Does this work with all types of garage doors in India?
Yes, as long as your garage motor has a wall-mounted push button, you can parallel-connect the relay. This covers rolling shutter motors (most common in India), sectional doors, and sliding gate motors. The relay mimics a button press regardless of the motor type.
What if my internet goes down?
When WiFi or internet is unavailable, Telegram control won’t work. Always maintain a physical backup: the original wall button. You could also add a GSM module (SIM800L) for SMS-based control when internet is down — useful in areas with unreliable broadband.
Is Telegram secure enough for controlling my garage?
Telegram uses strong encryption. The Chat ID whitelist ensures only authorised users can send commands. For additional security, add a PIN verification step in the bot conversation before accepting commands.
How far can the relay be from the garage motor controller?
The relay output can drive wires up to 30–50 metres. Use standard 2-core speaker wire or insulated alarm wire. The relay switches at low voltage (the motor’s control circuit), not at mains voltage, so long cable runs are safe and practical.
Can I share access with my building security guard?
Yes. Add the guard’s Telegram Chat ID to your whitelist. You can also create a separate Telegram bot token for the guard with limited commands (open only, no admin functions). Revoke access instantly by removing their ID from the whitelist.
Add comment