DIY ESP32 Telegram Flood Protection System - Smart Home Automation
How to build a highly reliable, automated Flood Protection System using an ESP32 microcontroller and a Telegram Bot for real-time remote monitoring and control.

- When the detected level is in air, due to reflect of the prism, most of light will enter receiver LED, optical level sensor will output high voltage.


A basic requirement when planning my project was the option to receive information about the current situation no matter where I am, via the mobile network on my smartphone. There are several services for this purpose, and I chose the Telegram platform because it allows the creation of bots that can perform automated tasks, and completely free of charge, so because of these conveniences it is often called a programmer's paradise.
So, if you haven't had one before, you need to open a Telegram account and create a bot.
Step-by-Step Guide: How to Create a Telegram Bot and Get Your Chat ID

1. Download and install Telegram if you haven’t already.
2. In the Telegram search bar, type @BotFather and select the official verified account.
3. Press the "Start" button to activate BotFather.
4. In the message box, type and send: `/newbot`
5. Enter a friendly name for your new bot (for example: `micemk_wateralarm_bot`).
6. Next, choose a unique Username for your bot. Note: It must end with `_bot` (for example: `Mircemk_bot`).
7. Once the username is accepted, BotFather will instantly generate an HTTP API Token. Make sure to copy and save this token securely, as you will need it for your ESP32 code.
Part 2: Obtaining Your Chat ID
1. In the Telegram search bar, search for your newly created bot username (e.g., @Mircemk_bot) and press "Start" to initialize it.
2. Go back to the Telegram search bar and search for a utility bot named: @IDBot
3. Open the chat with @IDBot and send the command: `/getid`
4. The bot will instantly reply with your unique, numeric Chat ID. Copy and save this number to use in your Arduino configuration.
It is important that when creating a telegram bot we get two distinct unique strings of characters, one is the HTTP API Token, and the other is the ID. We need this information later when creating the ESP32 code. Having already mentioned the code, I should say that it is designed in a way that can be easily changed several parameters, including the warning text that we receive on the smartphone.



Now I will simulate a flood in the house by filling this container with water. Here is how the system should behave. When the water rises to the sensor, ESP32 should automatically turn on the water pump, while the red LED will light up and the sound alarm will be activated, and at the same time we will receive a message on the smartphone that a flood has occurred. When the pump pumps the water to the required level, it automatically turns off and the user receives a message on the smartphone that the water has been removed and the room is dry. Instead of the blue LED, we can connect the solenoid valve from the main water supply via a relay and thus completely turn off the water supply remotely.

And finally a short conclusion. Integrating a software stability filter transforms a standard DIY sensor into a robust, industrial-grade protection system. Combined with the instant notifications of a Telegram Bot, this ESP32 project offers an incredibly efficient and affordable solution for smart home safety.

Discussie (0 opmerking(en))