Hi! I've connected a GSR sensor to GPIO 4 on an ESP32 and I'm using Blynk to monitor the values. When I comment out the Blynk part, the values are correct, but when I send the data through Blynk, I constantly receive a resistance value of 200 and sensor value its 0. I've checked the hardware connections and WiFi configuration. Below is the code I'm using. What could be causing this issue?
here is the code:// Include the library files
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define sensor 4
BlynkTimer timer;
char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
int sensorValue = 0;
int gsr_average = 0;
int Serial_calibration = 2048;
float Resistance = 0;
float reference_res = 100.0;
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
timer.setInterval(1000L, StressLevel);
}
void StressLevel() {
long sum = 0;
for(int i = 0; i < 10; i++) {
sensorValue = analogRead(sensor);
sum += sensorValue;
delay(10);
}
gsr_average = sum / 10;
Serial.print("GSR Average: ");
Serial.println(gsr_average);
Resistance = ((4096.0 + (2.0 * gsr_average)) / (2048.0 - gsr_average)) * reference_res;
Serial.print("Calculated Resistance: ");
Serial.println(Resistance);
if (!isnan(Resistance) && Resistance > 0 && Resistance < 1000000) {
Blynk.virtualWrite(V0, Resistance);
} else {
Serial.println("Invalid Resistance Value");
}
}
void loop() {
Blynk.run();
timer.run();
}
this is the library im using.