#define BLYNK_TEMPLATE_ID "TMPL3TFCN7hq8"
#define BLYNK_TEMPLATE_NAME "EV monitor"
#define BLYNK_AUTH_TOKEN "d370RMKF0Vmw4ri_6QOzNL02BlRuCmbp"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include "DHTesp.h"
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
const int DHT_PIN = 15;
DHTesp dhtSensor;
const int pir =23;
// Potentiometer is connected to GPIO 34 (Analog ADC1_CH6)
const int potPin = 34;
// variable for storing the potentiometer value
int potValue = 0;
BlynkTimer timer;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
pinMode(pir,INPUT);
timer.setInterval(1000L, sendData); // Send DHT data every 2 seconds
Serial.println("Hello, ESP32!");
}
void sendData() {
float t = dhtSensor.getTemperature();
if (isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" °C");
const int IP=digitalRead(pir);
Serial.print("Vibration: ");
Serial.println(IP);
potValue = analogRead(potPin);
float volts = 100* (potValue / 4096.0);
Serial.println("Battery Health: " + String(volts));
Blynk.virtualWrite(V2, t);
Blynk.virtualWrite(V1, IP);
Blynk.virtualWrite(V0, volts);
}
void loop() {
// put your main code here, to run repeatedly:
Blynk.run();
timer.run();
}