Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By flukee
#70598
schufti wrote:If you read the datasheet, you'll see that for measuring vcc the pin has to be floating (no external circuitry), so no use of changing mode 'on the fly'


The OP specifies the use of an external switchable component to float the pin. This change should be possible during runtime, at worst through a reset.
User avatar
By schufti
#70637 ok, so he could try to directly use sdk functions
system_adc_read
and
system_get_vdd33
and see how far this works / influences the further operation.

AFAIK this "preselection" ( ADC_MODE(ADC_VCC) ) determines if the esp_init_data[107]:vdd33_const is set to 255 (automatic Vdd measurement) or 33 (best guess value if A0 used external) for the binary.

Unfortunately the ESP8266 Non-OS SDK API Reference V2.1.1 has non clear notes regarding vdd33_const: In some note is only required to be 255 for reading Vdd or the "Vdd" replacement value instead for A0 use.
In other note it says if vdd33_const=255 A0 cannot work as ADC input.
So having 255 to initially measure Vdd and later call system_adc_read() to read A0 will probably not work.
Thats what most likely caused the later implementation of ADC_MODE(ADC_VCC), I think they had direct implementations of the sdk functions in the beginning.