//------------------------Pressure Sens-----------------
#include "HX711.h"
HX711 scale;
//------------------------Camera-------------------------
#include <ESP32Servo.h>
const int servoPin = 27;
Servo servo;
//--------------------------------------------------------------
#include<DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
DHT dht(13, DHT22 );
//pins Used
#define buzzer 12
const int pir =25;
void setup(){
Serial.begin(9600);
servo.attach(servoPin, 500, 2400);
scale.begin(18, 19);
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, LOW);
pinMode(pir,INPUT);
lcd.init();
lcd.backlight();
lcd.begin(20,4);
dht.begin();
}
int pos = 0;
void loop() {
lcd.setCursor(2, 0);
lcd.print("Baby Monitoring ");
lcd.setCursor(0, 2);
lcd.print("Location:");
digitalWrite(buzzer, LOW);
//----------------------------Temperature and Humidity----------------------------------
int h = dht.readHumidity();
int t = dht.readTemperature();
lcd.setCursor(0, 1);
lcd.print("Humi:");
lcd.print(h);
lcd.setCursor(13,1 );
lcd.print("Temp:");
lcd.print(t);
delay(2000);
if (t > 50)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.println("ALERT! HIGH TEMP");
digitalWrite(buzzer, HIGH);
delay(5000);
}
//----------------------------IR Sensor Configration-----------------
const int IP=digitalRead(pir);
Serial.println(IP);
delay(100);
if(IP==1){
lcd.setCursor(10,2);
lcd.println("Moving");
digitalWrite(buzzer,HIGH);
delay(1000);
}
if (IP == 0)
{
lcd.setCursor(10,2);
lcd.println("Normal");
// Serial.println("Normal Condition");
digitalWrite(buzzer, LOW);
}
//---------------------Camera For Baby Monitoring-----------------
for (pos = 0; pos <= 180; pos += 1) {
servo.write(pos);
delay(10);
}
// for loop that decreases the angle by 1 from 180 to 0 with a delay of 10 ms per angle
for (pos = 180; pos >= 0; pos -= 1) {
servo.write(pos);
delay(10);
}
//------------------------------Pressure Checking Code -----------------
Serial.println(scale.get_units(), 1);
int presure=scale.get_units();
lcd.setCursor(0, 3);
lcd.print("Presure:");
lcd.print(presure);
lcd.print("");
}