About ADC Calibration and usage
I'm reading the documentation about ADC:
And i have a couple of questions:
- Shall i calibrate both channels? is necessary to calibrate each pin?
- Since some inputs are only for input (otherwise it would damage the board) is not necessary to use them in order to calibrate?
- After measures are taken and the calibration process is done. Is necessary to do it again in case of re write the board with other script file?
@cocoa Thank you for your answer
@mfalkvidd Thank you for your answer
robert-hh last edited by
@nervencid The attenuation setting change the input voltage range for the ADC. With ATTN_D its is 0-1V, with ATTN_11DB it is ~0-3V. The range of the numbers you read form the ADC is always 0-4095, only at a different input voltage.
The factor associated with a dB attenuation number is 10**(dB_number/20). So for 0 it is 1, for 11 it is 3.548, for 6 it is 1.995
If i understand the problems of ESP32 is by fabrication and is not possible that they will not correct it in the future (is a pitty due it isn't recommendable for iot).
But the unique solution is to make some kind of linearization or interpolation in order to correct it, but i don't know if it works.
But i don't understand very well the concept of attenuation and how work properly with this parameter:
cocoa last edited by
@nervencid There is a lot of noise when reading the ADC. So first, you should take multiple measurements (say, 16 or 32 at least) and calculate the mean value. It's a good idea to switch of the noise sources on your board while measuring, at least everything "wireless" (WLAN, bluetooth, LTE...).
Secondly you need to do a calibration measurement run. Build a table with two columns: 1) mean value, 2) real value (measured externally by a reasonable good instrument).
Third, if you don't like to take too many points in step 2, you need to program a simple interpolation between the points (think of something like y=mx+b ...).
That will give you a quite usable ADC value for most applications.
It seems that the number of the pin measured, is 1090 , so it seems that is very minimum the difference for practicall purposes, anyway i don't have a power source avaible to make an accurate meassure
cocoa last edited by
ESP32 has the worst ADC on the market. Do not trust on it to make something else than a toy.
If you need real ADC use an external one.
mfalkvidd last edited by
Techinically, the calibration is for the internal reference voltage (vref), not for the ADC. Since the same vref is used for both channels and all pins, it is not necessary to calibrate both channels, nor each pin.
As long as you include adc.vref(your calibration number) in the script, there is no need to redo the calibration. However, each calibration number will be specific to a device, so you'll need to redo the calibration if you switch devices (even if you are using the same script).