• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

The ADC seems terrible.

Q&A Forum › Category: ESP32 › The ADC seems terrible.
0 Vote Up Vote Down
Daniel Lavin asked 6 years ago

In addition to the known and disclosed problem with linearity, there is also a considerable problem with noise.

With a pot connected and not moving, readings vary +/- 5%.  A large cap (47uF) across the input makes no difference.

Essentially this ADC appears to be useless except for the most gross measurements.

Am I missing something?

Question Tags: ADC
5 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Hello Daniel, unfortunately what you said is true.
The ESP32 ADC in non-linear and fails in accuracy.
It’s quite frustrating having a 12 bit ADC if its accuracy is so bad and it has so much noise.
For accurate measurements it’s definitely not recommend to use…

0 Vote Up Vote Down
ROSW answered 5 years ago

If what you are trying to measure is approximately 1/2 of the supply voltage, say a battery with a 10K/10K resistor divider this might be of help.  Create another 10K/10K resistor divider between the 3.3v supply and ground and measure it with another ADC input.  The result will be the value the ADC thinks is 1/2 of the supply voltage.  Use that to correct the battery voltage reading.  See below:

#define REF_mV 3300 // mV

// Read & return the battery voltage in milliVolts.
// Both the battery & supply voltages are halved
// using resistor dividers. This is done to get the ADC
// values in mid-range because of the non-linearities
// at the upper range.
uint16_t getBatVolts()
{
int REF_ADC;
int BAT_ADC;

// Get the reference supply voltage / DIV_VALUE
REF_ADC = analogRead(REF_PIN);

// Get the battery voltage / DIV_VALUE
BAT_ADC = analogRead(BAT_PIN);

// Calculate and return the battery voltage in milliVolts
return ((BAT_ADC * REF_mV) / REF_ADC);
}

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi.
Thanks for sharing that. That can be very useful for our readers.
We need to try that and see our results.
Regards,
Sara
 

0 Vote Up Vote Down
Steph answered 5 years ago

Hey everybody,

A few technical details may complement this discussion:

Analog to Digital Converter (by Espressif)

In particular, take a look at the following sections:

  • Minimizing Noise
  • ADC Calibration
0 Vote Up Vote Down
ROSW answered 5 years ago

I’ve read through that, unfortunately the calibration step is non-trivial and is required for each individual ESP32.  The voltage divider method described above does reduce the resolution some but is as accurate as the 3.3v supply voltage.  It is also generally limited to the lower two thirds of the ADC input range.  Not ideal but simple to implement and generally good enough in many cases.

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.