Simple voltage divider - ADC giving wrong readings?

Skyscraper1450
Posts: 2
Joined: Sun Jul 30, 2023 1:42 pm

Simple voltage divider - ADC giving wrong readings?

Postby Skyscraper1450 » Sun Jul 30, 2023 1:52 pm

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);
}
Attachments
1690725028862.jpg
1690725028862.jpg (3.57 MiB) Viewed 927 times

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: Simple voltage divider - ADC giving wrong readings?

Postby ESP_Sprite » Mon Jul 31, 2023 12:30 am

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.

Skyscraper1450
Posts: 2
Joined: Sun Jul 30, 2023 1:42 pm

Re: Simple voltage divider - ADC giving wrong readings?

Postby Skyscraper1450 » Mon Jul 31, 2023 7:56 am

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
Attachments
ADC linearity ESp32.png
ADC linearity ESp32.png (66.86 KiB) Viewed 888 times

Who is online

Users browsing this forum: top_secret_guy and 111 guests