ADC resolution in Python


I’m doing a battery monitor (ESP32 DevKitC with resistive divider for
1Vmax in A2), and the reading oscillates at the default resolution. When will there be the option to change the resolution via Python?


Hi cesarbudaye,
welcome in Zerynth community!
For the moment it is not possible to change ESP32 ADC resolution via Python but you can do it editing the ESP32 vhal_adc.c file (ADC hardware abstraction layer).
In particular, you just have to change the default ADC_WIDTH_12Bit constant (here the list of possible values) at line 23. For example, for 10 bit output code:

int vhalAdcInit(uint32_t adc, vhalAdcConf *conf) {
    return VHAL_OK;

The file to edit is in your user folder \zerynth2\dist\r2.0.10\vhal\xtensa-lx6\esp32\vhal_adc.c
Once you have edited the configuration you have to compile and uplink the project again.
Let us know if this can help you developing your project :slight_smile:


You were accurate in the solution. I changed the resolution parameter as well as the attenuation and improved. Big help.