#define BLYNK_TEMPLATE_ID "TMPL3N67vu7XE"
#define BLYNK_TEMPLATE_NAME "EVMONITOR"
#define BLYNK_AUTH_TOKEN "W_mg5mUFU9F9BxXg715swcrxhbEGABoo"
#include <WiFi.h>
#include<WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <NewPing.h>
#include <Thermistor.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
char auth[] = "W_mg5mUFU9F9BxXg715swcrxhbEGABoo";
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
#define TRIGGER_PIN 5
#define ECHO_PIN 18
#define THERMISTOR_PIN A0
#define BUZZER_PIN 19
#define MAX_DISTANCE 200
#define BUZZER_THRESHOLD 50
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
Thermistor thermistor(THERMISTOR_PIN);
BlynkTimer timer;
LiquidCrystal_I2C lcd(0x27, 16, 2); // Change the I2C address if necessary
void sendSensorData()
{
float distance = sonar.ping_cm();
float temperature = thermistor.readTempC(); // Read temperature in Celsius
Blynk.virtualWrite(V1, distance);
Blynk.virtualWrite(V2, temperature);
if (temperature > BUZZER_THRESHOLD) {
while(temperature>50)
{
digitalWrite(Buzzer, HIGH);
delay(2000);
digitalWrite(Buzzer, LOW);
delay(1000);
} //Turn on LED widget in Blynk
} else {
digitalWrite(BUZZER_PIN, LOW);
Blynk.virtualWrite(V3, 0); // Turn off LED widget in Blynk
}
// Display sensor readings on LCD
lcd.setCursor(0, 0);
lcd.print("Distance: ");
lcd.print(distance);
lcd.print("cm");
lcd.setCursor(0, 1);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print("C");
}
void setup()
{
Serial.begin(9600);
lcd.init();
lcd.backlight();
pinMode(BUZZER_PIN, OUTPUT);
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, sendSensorData);
}
void loop()
{
Blynk.run();
timer.run();
}