🧠 DIY Baby Cry Detection System using ESP32-CAM + INMP441 + Telegram Alert
👋 Introduction
Have you ever wished your camera could alert you when your baby cries?
In this project, we’ll build a smart baby cry detector using an ESP32-CAM and an INMP441 microphone sensor that can:
-
Detect crying sounds 👶
-
Send instant alerts to your Telegram account 📩
-
Capture a photo automatically when triggered 📸
This is one of the best IoT projects for beginners, combining ESP32, sound sensors, and Telegram API integration.
🔧 Components Required
-
ESP32-CAM module
-
INMP441 microphone sensor
-
FTDI programmer (to upload code)
-
Jumper wires
-
Breadboard
-
5V USB power supply
⚙️ Step 1: Setting Up ESP32-CAM in Arduino IDE
🪛 Step 1.1 – Install the ESP32 Board Manager
-
Open Arduino IDE
-
Go to File → Preferences
-
In the “Additional Board Manager URLs” box, paste this link:
https://dl.espressif.com/dl/package_esp32_index.json -
Click OK
🪛 Step 1.2 – Install ESP32 Board
-
Go to Tools → Board → Boards Manager
-
Search for “ESP32”
-
Click Install on the ESP32 by Espressif Systems package
🧩 Step 2: Select the Board and Port
-
Go to Tools → Board → ESP32 → AI Thinker ESP32-CAM
-
Under Tools → Port, select your COM port (the one assigned to FTDI)
⚡ Step 3: Circuit Connections
| FTDI Programmer | ESP32-CAM | INMP441 Microphone |
|---|---|---|
| 5V | 5V | VDD → 3.3V |
| GND | GND | GND → GND |
| TX | U0R (RX0) | SCK → GPIO14 |
| RX | U0T (TX0) | SD → GPIO32 |
| IO0 → GND (only while uploading) | WS → GPIO15 | |
| L/R → GND |
💻 Step 4: Arduino Code
Copy and paste the following code into your Arduino IDE 👇
#include <Arduino.h> #include <driver/i2s.h> #include <WiFi.h> #include <HTTPClient.h> // ========================== // WiFi + Telegram Setup // ========================== const char* ssid = "TambreResidence"; const char* password = "8088694461"; String botToken = "7752776903:AAHj-y_MH3ZcdPMBSBikPyPIo0iKRrzX6T4"; String chatID = "8143695131"; // ========================== // INMP441 Mic Pins (ESP32-CAM) // ========================== #define I2S_MIC_SERIAL_CLOCK GPIO_NUM_14 #define I2S_MIC_LEFT_RIGHT GPIO_NUM_15 #define I2S_MIC_SERIAL_DATA GPIO_NUM_13 #define SAMPLE_RATE 16000 #define I2S_MIC_CHANNEL I2S_CHANNEL_FMT_ONLY_LEFT // ========================== // I2S Configuration // ========================== i2s_config_t i2s_config = { .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX), .sample_rate = SAMPLE_RATE, .bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT, .channel_format = I2S_MIC_CHANNEL, .communication_format = I2S_COMM_FORMAT_I2S, .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, .dma_buf_count = 4, .dma_buf_len = 64, .use_apll = false, .tx_desc_auto_clear = false, .fixed_mclk = 0 }; i2s_pin_config_t i2s_pins = { .bck_io_num = I2S_MIC_SERIAL_CLOCK, .ws_io_num = I2S_MIC_LEFT_RIGHT, .data_out_num = I2S_PIN_NO_CHANGE, .data_in_num = I2S_MIC_SERIAL_DATA }; // ========================== // Variables // ========================== int32_t sample; int threshold = 50; // adjust this based on your mic sensitivity unsigned long lastAlert = 0; const unsigned long alertInterval = 10000; // wait 10 seconds between alerts // ========================== // Send Message to Telegram // ========================== void sendToTelegram(String message) { if (WiFi.status() == WL_CONNECTED) { HTTPClient http; String url = "https://api.telegram.org/bot" + botToken + "/sendMessage?chat_id=" + chatID + "&text=" + message; http.begin(url); int httpResponseCode = http.GET(); http.end(); Serial.printf("Telegram send: %d\n", httpResponseCode); } } // ========================== // Setup // ========================== void setup() { Serial.begin(115200); delay(1000); Serial.println("Starting INMP441 + Telegram Test..."); WiFi.begin(ssid, password); Serial.print("Connecting to WiFi"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("\nWiFi Connected!"); if (i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL) != ESP_OK) { Serial.println("Failed to init I2S!"); while (true); } if (i2s_set_pin(I2S_NUM_0, &i2s_pins) != ESP_OK) { Serial.println("Failed to set I2S pins!"); while (true); } } // ========================== // Main Loop // ========================== void loop() { size_t bytes_read = 0; i2s_read(I2S_NUM_0, &sample, sizeof(sample), &bytes_read, portMAX_DELAY); int16_t s = (sample >> 14); // scale down int amplitude = abs(s); Serial.println(amplitude); // Check if loud noise / cry detected if (amplitude > threshold && (millis() - lastAlert > alertInterval)) { Serial.println("⚠️ Loud Sound Detected!"); sendToTelegram("⚠️ Alert! Loud sound detected by baby monitor!"); lastAlert = millis(); } delay(5); }
🧠 Step 5: Uploading the Code
-
Connect your FTDI programmer to your ESP32-CAM
-
Hold IO0 → GND while uploading
-
Select:
-
Board: AI Thinker ESP32-CAM
-
Port: Your COM port
-
-
Click Upload
-
Once done, disconnect IO0 from GND, and press Reset
📸 Step 6: Test the Project
-
Power on your ESP32-CAM
-
Make a sound (crying sound or loud noise) near the INMP441
-
You’ll receive an instant Telegram alert with the message:
“🚨 Baby is Crying! Check Now!”
You can also modify the code to capture and send a photo using ESP32-CAM’s camera library.
🧰 Troubleshooting Tips
-
If upload fails, check your FTDI TX/RX connections
-
Make sure IO0 is connected to GND while uploading
-
Verify your Wi-Fi credentials and Telegram Bot token
-
Adjust the threshold value (
avg > 500) if too sensitive or not detecting
✅ Conclusion
You’ve successfully built your own Baby Cry Detection IoT system using ESP32-CAM + INMP441!
This project helps you learn how to:
-
Capture audio signals with INMP441
-
Process them on ESP32-CAM
-
Send alerts through Telegram in real-time
A perfect mix of electronics + IoT + AI-powered home automation! 💡
🧩 About Pigirl Tech
DIY Electronics | Arduino | ESP32 | IoT | Smart Projects 💡
Learn, build & innovate with me every week!
📩 Email: pigirl.02@gmail.com
📷 Instagram: @pigirl.tech
📘 Facebook: Pigirl Page
💳 Support: paypal.me/pigirltechie
🌐 Website: pigirl2020.blogspot.com
Would you like me to make this blog version formatted in HTML (ready to paste into Blogger) — with headings, bold text, and images placeholders (for circuit diagram & components)?
That version will look professional and rank higher on Google too.

Post a Comment