Chat with your board: read the sensor and switch the light from Telegram, anywhere.
Project_12_ESP32_Telegram_Bot.ino. Needs UniversalTelegramBot, ArduinoJson (v6+), and the DHT libraries, plus your Wi-Fi and a bot token.
Telegram runs a bot API over HTTPS. The ESP32 asks Telegram "any new messages?" once a second and acts on them, and it can also send you a message when something happens (motion).
Because it is just outbound HTTPS, this reaches your phone even on networks where a self-hosted web server would not.
| Command | What it does |
|---|---|
/status | temperature, humidity, light state |
/light_on · /light_off | switch the LED or relay |
/help | list the commands |
/newbot.bot. Copy the HTTP API token.Install: UniversalTelegramBot (Brian Lough), ArduinoJson (v6+), DHT sensor library, Adafruit Unified Sensor.
| Qty | Part | Notes |
|---|---|---|
| 1 | DHT11 | S to GPIO 4, + to 3.3 V, - to GND |
| 1 | LED + 220 Ohm or relay | to GPIO 26 |
| 1 | PIR (optional) | VCC to 5 V, OUT to GPIO 27, GND to GND |
Edit the marked block: WIFI_SSID, WIFI_PASS, BOT_TOKEN, and optionally CHAT_ID. Upload, open Serial Monitor at 115200, then send /start to your bot in Telegram.
============================================== Project 12: ESP32 Telegram Bot ============================================== Connecting to Wi-Fi: MyNetwork .... Wi-Fi connected! Bot ready. Open Telegram and send /start to your bot.
| Symptom | Likely cause | Fix |
|---|---|---|
| Bot never replies | Wrong token | Re-copy from BotFather |
Error on TELEGRAM_CERTIFICATE_ROOT | Wrong library | Use UniversalTelegramBot by Brian Lough |
| JSON compile error | Old ArduinoJson | Update to v6 or newer |
| No motion alerts | CHAT_ID empty or wrong | Get your id from @userinfobot |