Dual use of ADC; TOUT pin and measure Vcc
Posted: Wed Jul 26, 2017 3:26 pm
Hi all.
ESP8266 library reference says:
and
I want to know if anyone has been able to switch between TOUT pin and VCC modes of operation, in the one sketch. It seems like you choose one or the other, but can't have both.
In my application I have a MUX supplying the TOUT pin, which can be 'disconnected' to satisfy the requirement for leaving the TOUT pin free when taking Vcc measurements.
But it seems as though the ADC mode becomes 'locked in' at compile-time. Has anyone had success, or got a hack to use ADC to read VCC, and the TOUT pin? Ideas I have:
- an example hack that I think is unsuitable is to OTA a different firmware, read the VCC, then OTA initial firmware - sounds ridiculous
- can I use the firmware to modify the Flash binary to change the ADC mode, then reset? (a slightly better idea but still sounds dodgy)
Anyone done this?
Thanks
ESP8266 library reference says:
Note that by default ADC is configured to read from TOUT pin using analogRead(A0), and ESP.getVCC() is not available.
and
Add the following line to the top of your sketch to use getVcc: ADC_MODE(ADC_VCC);
I want to know if anyone has been able to switch between TOUT pin and VCC modes of operation, in the one sketch. It seems like you choose one or the other, but can't have both.
In my application I have a MUX supplying the TOUT pin, which can be 'disconnected' to satisfy the requirement for leaving the TOUT pin free when taking Vcc measurements.
But it seems as though the ADC mode becomes 'locked in' at compile-time. Has anyone had success, or got a hack to use ADC to read VCC, and the TOUT pin? Ideas I have:
- an example hack that I think is unsuitable is to OTA a different firmware, read the VCC, then OTA initial firmware - sounds ridiculous
- can I use the firmware to modify the Flash binary to change the ADC mode, then reset? (a slightly better idea but still sounds dodgy)
Anyone done this?
Thanks