#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPLFyrTmqyd"
#define BLYNK_DEVICE_NAME "Smart Farming"
#define BLYNK_AUTH_TOKEN "9OmeZRASSnDTgqPvi2IkhMC5RuhsSPG1"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
const float GAMMA = 0.7;
const float RL10 = 50;
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
BlynkTimer timer;
void sendSensor()
{
int analogValue = analogRead(34);
float voltage = analogValue * 5/4095.0;
float resistance = 2000 * voltage / (1 - voltage / 5);
float lux = pow(RL10 * 1e3 * pow(10, GAMMA) / resistance, (1 / GAMMA));
Serial.println(analogValue);
Serial.print("Lux: ");
Serial.println(lux);
Blynk.virtualWrite(V0, lux);
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
timer.setInterval(100L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}