Hi everyone, the ADC calibration issue has actually been addressed in the esp-idf. Please see
https://esp-idf.readthedocs.io/en/lates ... alibration
and
https://github.com/espressif/esp-idf/tr ... sp_adc_cal.
Essentially there is a chip to chip variation with regards to the internal LDO that supplies the reference voltage for the ADC on the ESP32. Ideally the ADC reference voltage should be 1100mV, however ESP32s can have reference voltages varying from 1000mV and 1200mV. Therefore the slope of the True Voltage vs ADC-Reading curve will be dependent on the chip's ADC reference voltage.
We've made a function that will route the ADC reference voltage to a GPIO pin so that users can then read the voltage manually with a multi-meter. See
https://esp-idf.readthedocs.io/en/lates ... gpio_num_t.
The reference voltage can then be input as a parameter in the function
of the the esp_adc_cal component. This function essentially calculates the correct shifting and scaling parameters (based on the reference voltage) needed to calibrate the ADC reading to the true voltage. Once the characteristics have been calculated, there is a function called
which uses the characteristics and various lookup tables included in the source files in order to convert the raw ADC reading (value from 0 to 4095) to a voltage in mV (for full details, see the API reference of the esp_adc_cal component).
esp-idf functions should be callable in Arduino as long as the correct header files are included. If I recall correctly, the header files that need to be included are
Code: Select all
#include "esp_adc_cal.h"
#include "driver/gpio.h"
#include "driver/adc.h"