Hello! I'm working on a project using Grove GSR sensor interfaced to ESP32. Initially, I interfaced and tested the sensor using Arduino Uno and it worked fine. However, when I interfaced the sensor to ESP32, the readings were not similar to those of the Arduino Uno and while adjusting the potentiometer, there were no displayed changes in the serial monitor. I've been working on it for days now but I have no progress at all. I would greatly appreciate any help from anyone who have worked on a similar project before.
Here is the code that I'm using for the ESP32 to read data from the GSR sensor.
//#include <LiquidCrystal_I2C.h>
//LiquidCrystal_I2C lcd(0x27,16,2);
const int GSR= 32; //ESP 32 analog pins 32-39
int sensorValue;
float Resistance;
float Conductivity;
int gsr_average;
float reference_res=100;
void setup()
{
Serial.begin(9600);
//lcd.begin(16,2);
//lcd.backlight(); // Make sure backlight is on
}
void loop()
{
//lcd.clear();
long sum=0;
for(int i=0;i<10;i++) //Get the mean of 10 measurements to remove the glitch
{
sensorValue=analogRead(GSR); //output is analog voltage
sum += sensorValue;
delay(5);
}
gsr_average = sum/10;
Serial.println(gsr_average);
Resistance = ((1024+(2*gsr_average))/(512-gsr_average))*reference_res;
//formula: Resistance = (2^10+(2sensorValue)/sensorValue)*referenceResistor
//2^10 = 1024, We measure the signal by voltage and print to COM port as (0~1023).
Conductivity = 1/(Resistance*0.001);
Serial.println(Resistance);
Serial.println(Conductivity,9);
//lcd.setCursor(0,0); //Set cursor to character 0 on line 0
//lcd.print("GSR in uS: ");
//lcd.setCursor(0,1); //Set cursor to character 0 on line 1
//lcd.print(Conductivity,9);
delay(1000);
}