Project Overview
This project creates a smart baby monitor that detects when your baby wakes up and sends an alert to your phone. Unlike traditional audio or video monitors, this system uses a PIR sensor to detect movement in the crib without intrusive cameras or microphones, preserving privacy while still alerting you when the baby is awake.
Difficulty: Intermediate
Estimated time: 2 hours
Estimated cost: $20-30
How It Works
A PIR sensor is positioned above or near the crib to detect motion. When the baby moves (wakes up), the ESP32 detects the motion and sends a notification to your phone via Blynk or Telegram. A sensitivity adjustment ensures small movements (like breathing) don’t trigger false alerts while larger movements (waking up) do.
Optional features include: a temperature sensor to monitor room temperature, a night light that turns on when motion is detected, and an audio playback module for lullabies.
Materials Needed
- ESP32 or ESP8266 (1)
- HC-SR501 PIR sensor (1) or AM312 for lower profile
- DHT22 temperature/humidity sensor (optional)
- RGB LED or WS2812B LED strip (for night light, optional)
- Buzzer (for local audible alert, optional)
- Jumper wires
- Power supply (5V 1A)
- Project enclosure
- Mounting bracket or adhesive tape
Blynk Setup
- Download Blynk IoT app and create an account.
- Create a new template for your baby monitor.
- Add a Notification widget.
- Add a Button widget for night light control.
- Add a Gauge widget for temperature display (if using DHT22).
- Note your BLYNK_TEMPLATE_ID and BLYNK_AUTH_TOKEN.
Circuit Diagram
Connection Table
| Component | Pin | ESP32 Pin | PIR Sensor | VCC | 3.3V | PIR Sensor | GND | GND | PIR Sensor | OUT | GPIO 4 | DHT22 | VCC | 3.3V | DHT22 | GND | GND | DHT22 | DATA | GPIO 5 | WS2812B LED | VCC | 5V | WS2812B LED | GND | GND | WS2812B LED | DATA | GPIO 6 | Buzzer | Positive | GPIO 7 | Buzzer | Negative | GND |
|---|
Arduino Code (Blynk IoT Platform)
// PIR Baby Monitor with Blynk
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
#include <FastLED.h>
// Blynk credentials
#define BLYNK_TEMPLATE_ID "YourTemplateID"
#define BLYNK_TEMPLATE_NAME "Baby Monitor"
#define BLYNK_AUTH_TOKEN "YourAuthToken"
// Wi-Fi credentials
char ssid[] = "YourWiFiSSID";
char pass[] = "YourWiFiPassword";
// Pin definitions
const int pirPin = 4;
const int dhtPin = 5;
const int ledPin = 6;
const int buzzerPin = 7;
// DHT sensor
#define DHTTYPE DHT22
DHT dht(dhtPin, DHTTYPE);
// LED strip
#define NUM_LEDS 8
CRGB leds[NUM_LEDS];
bool nightLightOn = false;
// Timing
unsigned long lastAlertTime = 0;
const unsigned long alertCooldown = 300000; // 5 minutes between alerts
bool motionDetectedFlag = false;
void setup() {
Serial.begin(115200);
pinMode(pirPin, INPUT);
pinMode(buzzerPin, OUTPUT);
digitalWrite(buzzerPin, LOW);
// Initialize LED strip
FastLED.addLeds<WS2812B, ledPin, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(64);
FastLED.clear();
// Initialize DHT
dht.begin();
// Connect to Blynk
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
Serial.println("Baby Monitor Ready");
Serial.println("Waiting 60 seconds for PIR warm-up...");
delay(60000);
}
// Night light control from Blynk app
BLYNK_WRITE(V0) {
nightLightOn = param.asInt();
if (nightLightOn) {
// Soft warm light
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB(255, 180, 100);
}
FastLED.show();
} else {
FastLED.clear();
FastLED.show();
}
}
void sendAlert() {
if (millis() - lastAlertTime > alertCooldown) {
Serial.println("Baby waking up! Sending alert...");
Blynk.logEvent("baby_wakeup", "Baby is waking up!");
lastAlertTime = millis();
// Local buzzer alert (soft beep)
tone(buzzerPin, 1000, 200);
delay(200);
tone(buzzerPin, 1500, 200);
// Turn on night light temporarily
if (!nightLightOn) {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB(255, 180, 100);
}
FastLED.show();
delay(10000); // 10 seconds
if (!nightLightOn) {
FastLED.clear();
FastLED.show();
}
}
}
}
void readAndSendTemperature() {
float temp = dht.readTemperature();
float humidity = dht.readHumidity();
if (!isnan(temp)) {
Blynk.virtualWrite(V1, temp);
Blynk.virtualWrite(V2, humidity);
}
}
void loop() {
Blynk.run();
bool motion = digitalRead(pirPin) == HIGH;
if (motion && !motionDetectedFlag) {
motionDetectedFlag = true;
sendAlert();
}
if (!motion) {
motionDetectedFlag = false;
}
// Send temperature every 30 seconds
static unsigned long lastTempRead = 0;
if (millis() - lastTempRead > 30000) {
readAndSendTemperature();
lastTempRead = millis();
}
delay(100);
}
Alternative: Telegram Bot Version (No Blynk Account Needed)
// Telegram Bot Version
#include <WiFi.h>
#include <UniversalTelegramBot.h>
#include <WiFiClientSecure.h>
const char* ssid = "YourWiFiSSID";
const char* password = "YourWiFiPassword";
const char* botToken = "YourTelegramBotToken";
const char* chatID = "YourChatID";
WiFiClientSecure client;
UniversalTelegramBot bot(botToken, client);
const int pirPin = 4;
unsigned long lastAlertTime = 0;
const unsigned long alertCooldown = 300000;
void setup() {
Serial.begin(115200);
pinMode(pirPin, INPUT);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
Serial.println("WiFi connected");
client.setCACert(TELEGRAM_CERTIFICATE_ROOT);
delay(60000); // PIR warm-up
}
void sendTelegramAlert() {
if (millis() - lastAlertTime > alertCooldown) {
String message = "Baby is waking up! 👶";
bot.sendMessage(chatID, message, "");
lastAlertTime = millis();
}
}
void loop() {
bool motion = digitalRead(pirPin) == HIGH;
if (motion) {
sendTelegramAlert();
delay(10000); // Debounce
}
delay(100);
}
Sensor Placement
Crib Placement
Mount the PIR sensor above the crib, angled downward to cover only the crib area. For a standard crib, mounting at 1-1.5m height, angled at 45°, provides coverage of the entire crib.
Adjusting Sensitivity
Adjust the sensitivity potentiometer so that small movements (breathing, turning head) do not trigger, but larger movements (sitting up, standing) do. This may take some trial and error.
Installation Steps
- Assemble circuit: Build on breadboard and test.
- Configure Blynk/Telegram: Set up notifications.
- Test motion detection: Wave hand to verify alerts.
- Mount sensor: Position above crib securely.
- Adjust sensitivity: Fine-tune to detect baby movement only.
- Test with baby: Observe for a few nights to ensure alerts are reliable but not excessive.
Project Extensions
- Temperature alerts: Send alert if room temperature is too hot or cold.
- Cry detection: Add sound sensor to detect crying.
- Lullaby player: Add DFPlayer Mini to play lullabies when motion detected.
- Night vision: Add infrared LEDs for low-light detection (PIR doesn’t need light).
- Data logging: Track sleep/wake patterns over time.
- Google Assistant integration: Ask “Is the baby awake?” and get response.
Troubleshooting
- Too many alerts: Reduce sensitivity or increase
alertCooldown. Adjust PIR sensitivity potentiometer. - No alerts: Check PIR sensor detects hand movement. Ensure Wi-Fi connection is stable.
- False alerts from airflow: Reposition sensor away from windows or vents.
- Temperature sensor not reading: Check wiring; DHT22 needs a 4.7k-10k pull-up resistor.
Safety Considerations
- Mount sensor securely out of baby’s reach.
- Use low-voltage components only (3.3V-5V).
- Ensure no cords are within reach of the crib.
- Test all components before placing near baby.
- This system is a supplement to, not a replacement for, attentive parenting.
Conclusion
This PIR-based baby monitor provides peace of mind without intrusive cameras or constant audio monitoring. You’ll know exactly when your baby wakes up, allowing you to respond promptly while preserving privacy.
