/* ESP32 WiFi Scanning example */
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <NewPing.h>
#include <LiquidCrystal_I2C.h>
// Blynk Auth Token
char auth[] = "";
// Your WiFi credentials
char ssid[] = "one plus nord ce3 lite ";
char pass[] = "gayathri2004";
// Ultrasonic sensor pins and maximum distance
#define TRIGGER_PIN1 5
#define ECHO_PIN1 18
#define TRIGGER_PIN2 4
#define ECHO_PIN2 19
#define TRIGGER_PIN3 17
#define ECHO_PIN3 16
#define MAX_DISTANCE 200 // Maximum distance in centimeters
NewPing sonar1(TRIGGER_PIN1, ECHO_PIN1, MAX_DISTANCE);
NewPing sonar2(TRIGGER_PIN2, ECHO_PIN2, MAX_DISTANCE);
NewPing sonar3(TRIGGER_PIN3, ECHO_PIN3, MAX_DISTANCE);
// LCD setup
LiquidCrystal_I2C lcd(0x27, 16, 2); // Change to your LCD's I2C address
// Buzzer pin
#define BUZZER_PIN 23
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
lcd.begin(16, 2);
lcd.init();
lcd.backlight();
pinMode(BUZZER_PIN, OUTPUT);
digitalWrite(BUZZER_PIN, LOW);
}
void loop() {
Blynk.run();
int distance1 = sonar1.ping_cm();
int distance2 = sonar2.ping_cm();
int distance3 = sonar3.ping_cm();
// Update LCD with waste levels
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Bin1: ");
lcd.print(distance1);
lcd.print("cm");
lcd.setCursor(0, 1);
lcd.print("Bin2: ");
lcd.print(distance2);
lcd.print("cm");
// Send distances to Blynk app
Blynk.virtualWrite(V1, distance1);
Blynk.virtualWrite(V2, distance2);
Blynk.virtualWrite(V3, distance3);
// Check waste levels and activate buzzer if necessary
if (distance1 < 10 || distance2 < 10 || distance3 < 10) {
digitalWrite(BUZZER_PIN, HIGH);
lcd.setCursor(9, 1);
lcd.print("ALERT!");
} else {
digitalWrite(BUZZER_PIN, LOW);
}
delay(1000); // Wait for 1 second before next measurement
}