Trying to read from a voltage divider circuit using two 240 Ohm resistors. Getting a reading of 6.0, when it should be 1.65. Circuit is powered by a bench 3.3V and both the Huzzah32 and circuit are grounded. Using USB for the Huzzah32. Any thoughts?
void setup()
{
Serial.begin(9600);
}
void loop()
{
int sensorValue = analogRead(A9);
float voltage = sensorValue * (3.3 / 1023.0);
Serial.println(voltage);
delay(1000);
}
1 Answer 1
First, ESP32 ADC is 12-bit, not 10-bit. therefore the formula should be:
float voltage = sensorValue * (3.3 / 4096.0);
Secondly, ESP32 ADC is not really linear, and tend to have lower reading than the actual value. You will need to do some calibration if you want to get a more accurate reading. You can take a look at my github on esp32-adc-calibrate.
both the Huzzah32 and circuit are grounded
... are the grounds joined? ... your schematic does not show a common ground