Saturday, 30 May 2026

AI Smart Baby Monitoring System with Cry and Motion Detection

AI Smart Baby Monitoring System with Cry and Motion Detection ESP32 + AI Agent + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI Smart Baby Monitoring System with Cry and Motion Detection ESP32 + AI Agent + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard 1. Project Overview This project is an AI-powered baby monitoring system that continuously monitors a baby's: Crying sounds Body movements Environmental conditions Sleep patterns The system uses: ESP32 as IoT Controller Sound Sensor for Cry Detection PIR Sensor for Motion Detection ThingSpeak Cloud Dashboard n8n Automation Workflow Telegram Bot Notifications Google Sheets Data Logging AI Agent Logic for Smart Decision Making Telegram Voice Alerts using Text-to-Speech The system can: ✅ Detect crying baby ✅ Detect excessive movement ✅ Send instant Telegram alerts ✅ Send voice notifications ✅ Log all events into Google Sheets ✅ Visualize live data on ThingSpeak ✅ Predict baby discomfort trends using AI logic 2. System Architecture +----------------------+ | Baby Room | +----------------------+ | | +----------------------+ | Sensors | |----------------------| | Sound Sensor | | PIR Motion Sensor | | Temperature Sensor | +----------------------+ | | +----------------------+ | ESP32 | +----------------------+ | WiFi | V +----------------------+ | ThingSpeak Cloud | +----------------------+ | | V +----------------------+ | n8n Server | +----------------------+ | | | | | | Telegram Google AI Agent Alert Sheets 3. Hardware Components List Component Quantity ESP32 Dev Board 1 Sound Sensor KY-037 1 PIR Motion Sensor HC-SR501 1 DHT22 Temperature Sensor 1 Buzzer 1 LED Indicator 1 Breadboard 1 Jumper Wires Several 5V Adapter 1 WiFi Network 1 4. Working Principle Cry Detection Sound sensor continuously monitors sound level. If Sound > Threshold | V Cry Detected ESP32 sends: { "event":"cry", "sound":92 } to ThingSpeak. Motion Detection PIR sensor detects movement. Motion = HIGH ESP32 sends: { "event":"motion", "movement":"active" } AI Agent Analysis n8n receives data. Rules: Cry + Motion = Baby Awake Cry + No Motion = Possible Discomfort No Cry + Motion = Restless Sleep No Cry + No Motion = Sleeping 5. Circuit Schematic Sound Sensor Sound Sensor -> ESP32 VCC -> 3.3V GND -> GND AO -> GPIO34 PIR Sensor PIR -> ESP32 VCC -> 5V GND -> GND OUT -> GPIO27 DHT22 DHT22 -> ESP32 VCC -> 3.3V DATA -> GPIO4 GND -> GND Buzzer Buzzer -> GPIO18 LED LED -> GPIO2 6. Pin Configuration #define SOUND_PIN 34 #define PIR_PIN 27 #define DHT_PIN 4 #define BUZZER_PIN 18 #define LED_PIN 2 7. Flowchart START | Initialize ESP32 | Connect WiFi | Read Sound Sensor | Read Motion Sensor | Read Temperature | Sound > Threshold ? | | YES NO | | Cry Event Continue | Send Data | Motion Detected ? | | YES NO | | Motion Continue | Upload ThingSpeak | Trigger n8n | Send Telegram Alert | Log Google Sheet | Repeat 8. ESP32 Source Code Install Libraries: WiFi.h HTTPClient.h DHT.h ThingSpeak.h Main Code #include #include #include #include char* ssid="YOUR_WIFI"; char* password="YOUR_PASSWORD"; unsigned long channelID = YOUR_CHANNEL_ID; const char* writeAPIKey="YOUR_API_KEY"; WiFiClient client; #define SOUND_PIN 34 #define PIR_PIN 27 #define DHT_PIN 4 DHT dht(DHT_PIN,DHT22); void setup() { Serial.begin(115200); pinMode(PIR_PIN,INPUT); WiFi.begin(ssid,password); while(WiFi.status()!=WL_CONNECTED) { delay(500); } ThingSpeak.begin(client); dht.begin(); } void loop() { int soundLevel=analogRead(SOUND_PIN); int motion=digitalRead(PIR_PIN); float temp=dht.readTemperature(); ThingSpeak.setField(1,soundLevel); ThingSpeak.setField(2,motion); ThingSpeak.setField(3,temp); ThingSpeak.writeFields(channelID,writeAPIKey); delay(15000); } 9. ThingSpeak Setup Create account: ThingSpeak Official Platform Create Channel Fields: Field1 = Sound Level Field2 = Motion Status Field3 = Temperature Field4 = AI Risk Score Dashboard Widgets Add: Gauge Line Chart Motion Indicator Temperature Chart Risk Score Chart 10. Telegram Bot Setup Open Telegram Search: BotFather Telegram Bot Creation Guide Commands: /start /newbot Example: BabyMonitorBot Receive: BOT_TOKEN Get Chat ID: https://api.telegram.org/botTOKEN/getUpdates Save: CHAT_ID 11. n8n Setup Install n8n n8n Official Website Docker: docker run -it --rm \ -p 5678:5678 \ -v ~/.n8n:/home/node/.n8n \ docker.n8n.io/n8nio/n8n Open: http://localhost:5678 12. n8n Workflow Logic Webhook Trigger | V Read Sensor Data | IF Cry? | YES | Telegram Alert | Google Sheet | ThingSpeak Update | AI Analysis | Voice Alert 13. n8n Workflow JSON Structure { "nodes":[ { "name":"Webhook", "type":"n8n-nodes-base.webhook" }, { "name":"IF Cry", "type":"n8n-nodes-base.if" }, { "name":"Telegram", "type":"n8n-nodes-base.telegram" }, { "name":"Google Sheets", "type":"n8n-nodes-base.googleSheets" } ] } Import this structure and configure credentials in n8n. 14. Google Sheets Integration Create Sheet: Baby Monitoring Log Columns: Timestamp Sound Motion Temperature Status Connect using: Google OAuth Credentials in n8n. Documentation: Google Sheets API Documentation 15. AI Agent Decision Engine Example rule engine: if sound > 80 and motion == 1: status = "Awake" elif sound > 80 and motion == 0: status = "Discomfort" elif sound < 30 and motion == 1: status = "Restless" else: status = "Sleeping" 16. AI Power Consumption Prediction Logic Track: Voltage Current Operating Hours WiFi Usage Formula: Power = Voltage × Current P=VI Prediction: daily_power = average_hourly_power * 24 monthly_power = daily_power * 30 AI Agent can estimate: Battery remaining Daily energy usage Maintenance interval 17. Voice Notification Automation Workflow: Cry Detected | V n8n | Google TTS | Generate MP3 | Telegram Send Voice Example message: Attention. Baby crying detected. Immediate check recommended. Useful services: Google Text-to-Speech API Telegram Send Voice Node Documentation: Google Cloud Text-to-Speech 18. AI Agent Enhancements You can integrate: OpenAI Platform Ollama Local AI Models LangChain Framework Advanced analysis: Analyze last 24 hours Detect: - Frequent crying - Sleep interruptions - Temperature abnormalities Generate daily report Example AI report: Baby Sleep Score: 82% Cry Events: 7 Motion Events: 24 Recommendation: Check room temperature. 19. Deployment Guide Stage 1 Build hardware. Stage 2 Upload ESP32 code. Stage 3 Verify WiFi connection. Stage 4 Create ThingSpeak Channel. Stage 5 Create Telegram Bot. Stage 6 Install n8n. Stage 7 Connect: ESP32 ↓ ThingSpeak ↓ n8n ↓ Telegram ↓ Google Sheets Stage 8 Test Events Clap near sensor → Cry event Move in front of PIR → Motion event Verify: Telegram notification Google Sheets entry ThingSpeak graph update 20. Future Enhancements AI Features Real cry classification using TinyML Baby face recognition Sleep quality prediction Fever prediction Abnormal behavior detection Hardware Upgrades ESP32-CAM MLX90614 IR thermometer Microphone array Battery backup OLED display Cloud Enhancements Mobile app Firebase integration AWS IoT integration Voice assistant support Multi-room monitoring Expected Project Outcome The final system becomes a complete Agentic AI Baby Monitoring Platform capable of: Real-time cry detection Motion monitoring Cloud analytics AI decision making Telegram text alerts Telegram voice alerts Google Sheets logging ThingSpeak dashboard visualization Power usage prediction Daily baby activity reporting This architecture is suitable for final-year engineering projects, IoT research prototypes, smart nursery deployments, and AI-enabled healthcare monitoring demonstrations.

No comments:

Post a Comment

AI Smart Refrigerator Monitoring and Food Expiry Detection

AI Smart Refrigerator Monitoring & Food Expiry Detection System ESP32 + Agentic AI + n8n Automation + Telegram Voice Alerts + Google She...