Hello everybody, I just don't get this. I wanted to verify that my TDS sensor was in fact receiving 5V. So. I connected PIN 5V of my ESP32 and ran the following program. Why does it say 20V on the serial monitor? Thank you.
int SensorValue =0;
#define VoltageSensorPin 34
void setup() {
Serial.begin(9600);
pinMode(34, INPUT);
}
void loop() {
SensorValue = analogRead(VoltageSensorPin);
float voltage = SensorValue * (5.0 / 1023.0);
Serial.println(voltage);
delay(1000);
}
The aboving scaling is completely wrong for the ESP32, which (by the way) has a lousy, nonlinear ADC , not really suitable for use with your TDS meter.
Try something like this, depending on what you have set for the analog reference (default 3.3V, I think):
float voltage = SensorValue * (3.3 / 4096.0);
DO NOT expose any I/O pins to 5V! Use a 2:1 voltage divider to measure 5V (2 10K resistors in series). You may already have trashed the ADC input.
1 Like
oh crap I hope not. ok thank you.
system
Closed
March 29, 2024, 11:10pm
4
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.