Hi guys,
I need just a confirmation that what I am doing is right.
I have connected the Grove TDS Sensor (Grove - TDS Sensor | Seeed Studio Wiki) to the ESP32 NodeMCU CP2102, and at the beginning I was simply testing it with the code available in the link and that you can find there:
#define SERIAL Serial
#define sensorPin A0
int sensorValue = 0;
float tdsValue = 0;
float Voltage = 0;
void setup() {
SERIAL.begin(9600);
}
void loop() {
sensorValue = analogRead(sensorPin);
Voltage = sensorValue*5/1024.0; //Convert analog reading to Voltage
tdsValue=(133.42*Voltage*Voltage*Voltage - 255.86*Voltage*Voltage + 857.39*Voltage)*0.5; //Convert voltage value to TDS value
SERIAL.print("TDS Value = ");
SERIAL.print(tdsValue);
SERIAL.println(" ppm");
delay(1000);
}
After starting to lose my patience, I just tried to understand what was going on (value out of range), and, sadly, I just figure out that Analog Pin on ESP32 have a resolution of 12 bits and not 10 like on arduino.
So I needed to change the Voltage calculation in the code above.
This is what I have done, and results seem to be right now...
Voltage = sensorValue*3.3/4095; //Convert analog reading to Voltage
Could you confirm that this is right?
I am pretty sure about the analog maximum of 4095, but what about the 5? I thought it was related to input voltage on the sensor (for this I have tried to use 3.3 because I was considering to use the 3.3V as power input) but I see that if I switch input voltage from 5 to 3.3 results don't change
So I have to keep it at 5? And in this case could you pls explain why?
Best,
Fabio