// [email protected]
// kist@2024

#define BLYNK_TEMPLATE_ID "TMPL6oeiTEl3b"
#define BLYNK_TEMPLATE_NAME "SOLAR PANEL ELECTRICITY MONITORING"
#define BLYNK_AUTH_TOKEN "Sb5mSTtz2KD-vvLVx47cATFZVTeHagGJ"

#define CURRENT_SENSOR      34
#define VOLTAGE_SENSOR      35

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";

float Current,Voltage;

void setup()
{
 Serial.begin(9600);
 Blynk.begin(auth, ssid, pass);
}

void loop()
{
 Blynk.run();
 get_data();
 send_update();
 delay(1000);
}

void get_data() 
{
  Current=map(analogRead(CURRENT_SENSOR),0,4095,0,1200);
  Serial.print("current:");
  Serial.println(Current);
  Voltage=map(analogRead(VOLTAGE_SENSOR),0,4095,0,17);
  Serial.print("voltage:");
  Serial.println(Voltage);
}

void send_update() 
{     
  Blynk.virtualWrite(V0,Current);
  Blynk.virtualWrite(V1,Voltage);
}
IoT BASED SOLARPV MONITORING SYSTEM
CURRENT SENSOR
VOLTAGE SENSOR