Page 1 of 1

Simple voltage divider - ADC giving wrong readings?

Posted: Sun Jul 30, 2023 1:52 pm
by Skyscraper1450
Hello everyone,

so I have been experimenting with an ESP32, building a simple voltage divider to test the ADC.
As i have been using R1 = R2 = 1000 Ohm I was expecting to read 1.65V or a data value of 4096/2 = 2048.
However I am just reading ~1700 which corresponds to ~1.36 V.
I checked this with a multimeter too, where i received exactly what i was expecting, 1.65 V.
I even added a capacitor as i read that that could help with false readings, but that didn't change anything

What could be the issue here? Code below and image from the board

Code: Select all

const int analogPin=35;
int U2;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200); 
}

void loop() {
  // put your main code here, to run repeatedly:
  
  U2 = analogRead(analogPin);
  Serial.println(U2);

  delay(500);
}

Re: Simple voltage divider - ADC giving wrong readings?

Posted: Mon Jul 31, 2023 12:30 am
by ESP_Sprite
You are assuming the ADC uses a reference voltage of 3.3V. This is not the case; it uses around 1.1V but it has internal attenuators that allow you to measure higher ranges than that. I don't exactly know how that works on an Arduino level, though.

Re: Simple voltage divider - ADC giving wrong readings?

Posted: Mon Jul 31, 2023 7:56 am
by Skyscraper1450
You are right I did assume that. However i found this image which confirms that the voltage range is 3.3 V. Maybe it can also explain the error that im facing, in which case the "wrong" reading is related to the non linearity of the ADC. I have heard of the non-linearity of ADCs before, but i had no idea it could be this severe