Tech Note 151 - ESP32 ADC Accuracy Improvement using the ADC reference voltage to correct readings.

preview_player
Показать описание
Extracting the ESP32 ADC reference voltage to improve ADC reading accuracy. The 'esp_adc_cal/include/esp_adc_cal.h' API provides an API to allow for corrections in measured voltages caused by variation of ADC reference voltages (Vref) between chips. By-design the ADC reference voltage is 1100 mV, however the true reference voltage can vary from device-to-deice and range from 1000 mV to 1200 mV amongst different ESP32's. Reading the reference voltage enables a correction to be made which then improves ADC reading accuracy.
There is also an example for the Lolin D32 board with on-board /2 voltage divider (code V2).
Рекомендации по теме
Комментарии
Автор

OMG, "preferred Value", first time I've heard this reference used. Your excellent explanation makes sense. I also just watched your new video related to Improving ADC accuracy, “Tech Note 151 - ESP32 ADC Accuracy Improvement using the ADC reference voltage”

FYI: I’m working on ESP-01 battery-powered sensors and want to be notified when the batteries drop below ~ < 3.0. This helps!

bgable
Автор

Omg I was pissed because the esp32 don't read milivolts accurately. Thanks man!!

omniyambot
Автор

Thank you Dave.
Nice to have great news from you always.
Marc.

MPElectronique
Автор

Thank you for your great tutorials on ESP32!
Please make a tutorial on flash encryption and secure boot.
There is no tutorial available on this that explains this in a simple manner.
How do we protect our code from being unauthorised reads.
This is the only reason keeping me from using ESP32 for more serious applications.
Thank you!

roycejp
Автор

David, thanks for your many contributions to the ESP32 community. I've learned much from your tech notes on Youtube! Thank you. I implemented this setup to calibrate the ADC and I have observed on both of my ESP32 Dev Modules (both are ESP32-WROOM-S2) very poor ADC repeatability - with some measurements spot on but many ranging out as far as +/- 0.15 volts in error. My DC source is a rock solid HP benchtop unit that my HP benchtop multimeter shows outputting a steady +3.0063 VDC. I downloaded your sketch so there is nothing else running on the processor. However, I have noticed the same phenomena using other code (I wrote) so there is something The variance is unacceptably high and I'm trying to chase down the source if it. I even modified your code to include a for loop and average multiple results to try to reduce the noise but this had no effect. So maybe something within the ESP32 board is impacting results...

Is it a common trait of the ESP32 ADC's to have "marginal" repeatability? Or is this what I should expect? I would expect this not to be the case since trying to improve measurement accuracy to < 1% would be moot if the system is not repeatable in the first place... Any ideas?

stevel
Автор

Having a strange issue here. I have a voltage divider set up so I can read an external battery. With the resistors I picked, I should be getting 1.81 volts according to the calculators. And my multimeter confirms that. My ESP32 reads 1.68 volts. Figured I'd look into calibrating it.

Problem is, when I run your code it brings my reading DOWN to 1.65. The vref is 1121 apparently. Would it be fine to increase the calibration to 1.094? Or would it make more sense to adjust the vref manually in your calculations? Thanks!

Going to test some other ESP32 I have too, one is a different board setup so maybe it's just the manufacturer of this board. It's a NodeMCU 32s, v1.1 I think.

NavyPanther
Автор

Thank you David just what i needed right now

alainclarke
Автор

Would you please explain what line 24 does? The code is:

esp_adc_cal_characteristics_t adc_chars;

Thanks very much

brianh
Автор

Thanks for this video ! I was just wondering how did you calculate the 2.174 value (on the github). My board has a on-board voltage divider and it's written on the datasheet to multiply by 2 the data (and not by 2.174). It's the HUZZAH 32 Feather by Adafruit. Thanks

clementbeschu
Автор

Have you tried using mega ohm resistors to reduce power consumption in voltage dividers? Was wondering how that also impacts the accuracy of the adc readings.

blakefl
Автор

Love your useful and well explained. Thanks for sharing.

keen
Автор

Hi David, been using the code from your Tech Note 069 for about a year. Today I "upgraded" the Espressif core in the Arduino IDE from 1.0.1 to 1.0.6 and now got compiler errors:
esp32Target.cpp:1499:27: error: 'adcStart' was not declared in this scope
adcStart(boxXaxis);
^
esp32Target.cpp:1500:32: error: 'adcBusy' was not declared in this scope
while(adcBusy(boxXaxis)) {;}
^
esp32Target.cpp:1501:34: error: 'adcEnd' was not declared in this scope
work1 += adcEnd(boxXaxis);

Any chance you could point me to what to do? Thanks
^

ppedfw
Автор

100th like \o/ Seriously helpful video. Thanks David!

TheAstronomyDude
Автор

That good info. I switched from Arduino to ESP32, thinking this was the greatest thing since sliced bread, dual core, 4 times the speed, Bluetooth, WiFi. Then when trying to measure low voltages with the ADC it didn't seem to work as well as the Arduino. Not sure if there is any fix for that.

TheModelmaker
Автор

Thanks for the useful solution. I am, so far, unable to find a .zip file for the esp_adc_cal library as a download for the Arduino IDE. I have looked in github and otherwise googled for it but am coming up dry. Can you tell me where I can find it?

dennycarlyle
Автор

Arduino has AREF, so when using it no calibration is needed. Which is better design?

ButilkaRomm
Автор

Is something similar for esp8266. I'm suffering from random noise jumps every few seconds

solidfuel
Автор

Esp just crashes: E (75) ADC: CONFLICT! driver_ng is not allowed to be used with the legacy driver

lucasmontec
Автор

Thanks Dave! :) I will try :)

Thanks.
Marc.

MPElectronique
Автор

Dave, a int is : This yields a range of -32, 768 to 32, 767 ;-( how can this works ?

MPElectronique