This is an old revision of the document!
The baby monitoring system provides a way for parents to track the baby's sleeping environment by tracking the light levels, the sound and the temperature. When a certain threshold is reached the system alerts the parents by email. The system also stores the sensor data and generates weekly reports for the parents.
2 pins are used for the 2 sensors: 4 and 34
#define DHTPIN 4 #define DHTTYPE DHT11 #define SOUND_ANALOG_PIN 34
Sensor reading and writing
void sendSensorData() {
float temp = dht.readTemperature();
float hum = dht.readHumidity();
int soundLevel = analogRead(SOUND_ANALOG_PIN);
if (isnan(temp) || isnan(hum)) {
Serial.println("Failed to read from DHT sensor");
return;
}
Serial.printf("Temp: %.1f °C | Humidity: %.1f %% | Sound: %d\n", temp, hum, soundLevel);
Blynk.virtualWrite(V1, temp);
Blynk.virtualWrite(V2, hum);
Blynk.virtualWrite(V3, soundLevel);
Event generation
if (temp > 21) {
Blynk.logEvent("high_temperature", "Temperature too high!");
Serial.println("Temp big enough");
}
if (hum < 30) {
Blynk.logEvent("low_humidity", " Humidity too low!");
}
if (soundLevel > 40) {
Blynk.logEvent("high_noise", "High noise level detected!");
}
}