Skip to content

mskian/esp32-dht22-telegram

Repository files navigation

ESP32 DHT22 Telegram Bot

A real-time IoT project using ESP32 + DHT22 to monitor temperature and humidity and send data via a Telegram bot.

A real-time IoT project using ESP32 + DHT22 to monitor temperature and humidity

A real-time IoT project using ESP32 + DHT22 to monitor temperature and humidity

Telegram Bot Update

🔥 Features

  • 🌡 Temperature & 💧 Humidity monitoring
  • 🤖 Telegram bot commands
  • 📊 Live system status (/data)
  • 😄 Smart “feel” messages (/feel)
  • 🔐 Secure (only allowed users)
  • ⚡ Async & non-blocking design
  • 🧠 Moving average filtering for stable readings

📸 Hardware Setup

ESP32 Dev Board + DHT22 Sensor

Wiring:

it requires 3 Jumper Wires

Wiring

DHT22(sensor)	 ESP32(module)

+       3V3  
-       GND  
OUT      D4  

⚙️ Setup

  1. Install Arduino IDE
  2. Install ESP32 board support
  3. Install ESP32 Board in Arduino IDE
  4. Open Arduino IDE
Go to:
File → Preferences

Add this URL in Additional Board Manager URLs:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

Go to:
Tools → Board → Boards Manager
Search: esp32
Install: esp32 by Espressif
  1. Install Libraries (Go to Library Manager)
DHT sensor library (Adafruit)
UniversalTelegramBot
ArduinoJson

6 - Select Your Board

Tools → Board → ESP32 Dev Module
Tools → Port → /dev/ttyUSB0  (or similar)

🤖 Telegram Bot Setup

  • Open Telegram → @BotFather
  • Run:

/newbot

  • Copy your BOT TOKEN

🔑 Configuration

Choose Anyone of the Code below based on your usage:

  • esp32_dht22_telegram_bot.ino: for faster response and consume more energy
  • esp32_dht22_optimized_bot.ino: Optimized and deplay in bot response (recommended)
  • esp32_dht22_web_bot.ino: Telegram Bot + web view with Real-time Live Data + Telegram Trigger Button (recommended)

Edit the code:

const char* ssid = "YOUR_WIFI_NAME"; // it support 2G WIFI Only
const char* password = "YOUR_PASSWORD";
const char* BOT_TOKEN = "YOUR_BOT_TOKEN";
const char* ALLOWED_IDS[] = {
  "YOUR CHAT ID"
};

🚀 Upload

  • Select ESP32 Dev Module
Tools → Board → ESP32 Dev Module
Select Port : /dev/ttyUSB0
  • Upload via Arduino IDE - Click Upload

📱 Telegram Bot Commands

  • Command Description
start - 👍 Start the bot
data - 🔌 Show system + sensor status
feel - 😛 Funny weather feeling
temperature - ☀️ Get temperature
humidity - 🔥 Get humidity

⚠️ Notes

  • DHT22 updates every ~2 seconds (hardware limitation)
  • Use 3.3V (not 5V)
  • Avoid rapid polling

Credits

LICENSE

MIT License

About

A real-time IoT project using ESP32 + DHT22 to monitor temperature and humidity and send data via a Telegram bot.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages