🚨 SEND ALERT TO TELEGRAM BOT 🚨

I used an ESP32 with an OV7670 camera and an LD2420 radar motion sensor.
The LD2420 detects human presence, breathing, and heartbeats using millimeter-wave technology.
It can count people and measure their distance precisely.
The OV7670 camera captures real-time images to support visual monitoring.
All collected data and images are sent automatically to a Telegram bot for remote alerts
- To create a new bot, go to @BotFather on Telegram and send the command
/newbot. - After you choose a name for your bot, select a username it must end with
_bot - Now you have your token it is very important for the code to connect to Telegram.
- You can revoke your token anytime by sending
/revoketo @BotFather and you will immediately receive a new token. - To get your Chat ID, send a message to your bot, then open your browser and go to
https://api.telegram.org/bot****YOUR_BOT_TOKEN****/getUpdatesand you will get your Chat ID from the JSON response.
-
Don’t forget to set up your Wi-Fi connection before running the code
const char* ssid = "****************************";
const char* password = "****************************"; -
And make sure your Telegram connection is properly configured.
const char* BOT_TOKEN = "*********************************";
const char* CHAT_ID = "***********************************"; -
You need to wire the pins according to the Pin Configuration (ESP32 + OV7670 + LD2420) table.
| Component | Function | ESP32 Pin | Description / Notes |
|---|---|---|---|
| Camera (OV7670) | VCC | 3.3V | Power supply for camera (use 3.3V only |
| GND | GND | Common ground with ESP32 | |
| PWDN | -1 | Power down (not used) | |
| RESET | 18 | Camera reset pin | |
| XCLK | 32 | External clock for camera | |
| VSYNC | 34 | Frame sync | |
| HREF | 35 | Horizontal reference | |
| PCLK | 33 | Pixel clock | |
| D0 | 19 | Data bit 0 | |
| D1 | 23 | Data bit 1 | |
| D2 | 13 | Data bit 2 | |
| D3 | 12 | Data bit 3 | |
| D4 | 14 | Data bit 4 | |
| D5 | 27 | Data bit 5 | |
| D6 | 26 | Data bit 6 | |
| D7 | 25 | Data bit 7 | |
| SDA | 21 | I2C data line | |
| SCL | 22 | I2C clock line | |
| LD2420 Sensor | VCC | 3.3V | Power supply for LD2420 ( |
| GND | GND | Common ground with ESP32 | |
| RX (to LD2420 TX / OT1) | 16 | Serial RX2 (ESP receives data) | |
| TX (to LD2420 RX) | 17 | Serial TX2 (ESP sends commands) |
💡 Notes:
- Both the OV7670 and LD2420 must be powered from the 3.3V pin of the ESP32 — never use 5V!
- Always connect all GND pins together (ESP32, OV7670, LD2420) to ensure a stable signal reference.
- Check wiring carefully before uploading code to avoid damaging components.
-
In the LD2420 sensor, you can set the detection limit using MAX_DETECTION_CM in main Example:
const int MAX_DETECTION_CM = 700;The sensor supports a maximum range of up to 8 meters -
This code starts the web server on port 80 and sends the ESP32’s IP address to the Telegram bot so you can access the live camera stream directly from the link
Serial.println("Open the browser at: http://" + WiFi.localIP().toString());
You can design or 3D print a custom case to hold the ESP32, OV7670 camera, and LD2420 sensor.
Make sure to leave openings for the camera lens, power cable, and ventilation.
Use lightweight materials such as PETG for the best results.
In my design, I used Blender for modeling and editing the case.

form the 3DFile folder the project includes two files:




