A real-time IoT project using ESP32 + DHT22 to monitor temperature and humidity and send data via a Telegram bot.
- 🌡 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
ESP32 Dev Board + DHT22 Sensor
it requires 3 Jumper Wires
DHT22(sensor) ESP32(module)
+ 3V3
- GND
OUT D4 - Install Arduino IDE
- Install ESP32 board support
- Install ESP32 Board in Arduino IDE
- 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- Install Libraries (Go to Library Manager)
DHT sensor library (Adafruit)
UniversalTelegramBot
ArduinoJson6 - Select Your Board
Tools → Board → ESP32 Dev Module
Tools → Port → /dev/ttyUSB0 (or similar)- Open Telegram → @BotFather
- Run:
/newbot
- Copy your BOT TOKEN
Choose Anyone of the Code below based on your usage:
esp32_dht22_telegram_bot.ino: for faster response and consume more energyesp32_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"
};- Select ESP32 Dev Module
Tools → Board → ESP32 Dev Module
Select Port : /dev/ttyUSB0- Upload via Arduino IDE - Click Upload
- Command Description
start - 👍 Start the bot
data - 🔌 Show system + sensor status
feel - 😛 Funny weather feeling
temperature - ☀️ Get temperature
humidity - 🔥 Get humidity- DHT22 updates every
~2seconds (hardware limitation) - Use 3.3V (not 5V)
- Avoid rapid polling
- Room temperature and humidity with ESP8266, DHT11, and a Telegram bot - https://github.com/mcnaveen/esp8266-dht11-telegram
- Universal Telegram Bot Library - https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot
- ESP32 and DHT22: Learning Hardware Selection the Hard Way - https://medium.com/@ummugulsun/esp32-and-dht22-learning-hardware-selection-the-hard-way-49d2589050c2
- Youtube Demo Video: https://www.youtube.com/shorts/qvT4jK5xQgs
MIT License



