Skip to content
AdvancedESP32esp32home-automationtelegram

ESP32 Smart Home Automation with Relay & Telegram Bot Control

Control your home appliances from anywhere using ESP32, a 4-channel relay module, and Telegram Bot. No cloud subscription needed — just your phone.

SolderHub10/17/2026 20 min read 0 views

The Idea

I got tired of getting up to turn off the fan at night. Sounds lazy, I know. But that's honestly how this project started — lying in bed, too warm, too comfortable to move.

So I built a Telegram-controlled relay switch using my ESP32. Now I control four appliances from my phone — fan, lights, water pump, and a desk lamp — without any monthly subscription or cloud service.

Here's the full build.


What You'll Need

Hardware:

  • ESP32 DevKit v1
  • 4-channel 5V relay module
  • Jumper wires (male to male)
  • USB power adapter (5V 2A minimum)
  • Any AC appliance to control (start with a lamp — safer)

Software:

  • Arduino IDE (2.x recommended)
  • Libraries: WiFi.h (built-in), UniversalTelegramBot, ArduinoJson

How It Works

The ESP32 connects to your WiFi. It then polls the Telegram Bot API every 1.5 seconds using an HTTPS GET request. When you send /fan on from your phone, the ESP32 reads the message, triggers GPIO pin 26, and the relay clicks ON.

Simple. Reliable. No middleman.


Circuit Connections

Relay Module PinESP32 Pin
IN1GPIO 26
IN2GPIO 27
IN3GPIO 14
IN4GPIO 12
VCC5V (VIN)
GNDGND

⚠️ Never connect AC mains directly without proper insulation. Use pre-wired relay boards with terminal blocks.


C++

Setting Up Your Telegram Bot

  1. Open Telegram → search @BotFather
  2. Send /newbot → give it a name → get your token
  3. Search @userinfobot → send /start → copy your Chat ID
  4. Replace the token and chat ID in the code above

Troubleshooting

Bot not responding?

  • Check your WiFi credentials
  • Make sure Chat ID matches exactly (can be negative for group chats)
  • Some ISPs block Telegram — try a different network

Relay clicking but appliance not working?

  • Check if your relay is active LOW or active HIGH
  • Most blue relay modules are active LOW (LOW = ON)

ESP32 keeps restarting?

  • Relay module drawing too much current from 3.3V pin
  • Power the relay VCC from 5V (VIN pin), not 3.3V

What's Next?

Once this works, you can add:

  • A small OLED display showing appliance status
  • Scheduled ON/OFF using NTP time
  • Voice control via Google Assistant + IFTTT

The foundation is solid. Build on it.


Build Sheet

Take this build with you

We'll email you the parts list for ESP32 Smart Home Automation with Relay & Telegram Bot Control, with buy links and the Wokwi and source links, so you can order and build later. You'll also get new builds as they're published.

By subscribing you agree to our Privacy Policy. Unsubscribe anytime.

Q&A is currently disabled site-wide.

Related projects