-
On ESP32S3, I create an ADC pin, and read it using read_uv() (converting to mV in the example below).
So thats fine (this is the value I expect, basically half of my battery voltage due to resistor divider)
and thereafter the value is bad... A reset will return to the good value, but just re-creating the ADC pin or doing adc.init() won't. What needs to be reinitialised/started to get the ADC to work after sleeping? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Are you using the WiFi on that board? |
Beta Was this translation helpful? Give feedback.
-
I wasn't aware that you could set adc.init(hold=True)
lightsleep()
adc.int(hold=False) also the line: adc = machine.ADC(machine.Pin(14, mode=machine.Pin.IN, pull=None), atten=machine.ADC.ATTN_11DB) might need changing. What happens if you leave |
Beta Was this translation helpful? Give feedback.
-
Did you measure the voltage at Pin14 when it tells 3109.0? e.g. with a multimeter |
Beta Was this translation helpful? Give feedback.
-
After some digging I found its a ESP32S3 chip bug which causes it to lose its ADC calibration register values during lightsleep(). There is a commit for esp_idf_4.4 to fix it: espressif/esp-idf@32afe6a Strangely my esp_idf_4.4 download doesnt have the fix, so I just added the save/restore functions to my esp32ext module (along with the gpio wake setup I needed to wake on a gpio on this MCU)
If you have a later batch of the chip, or a more recent IDF, you might not need this. In any case, its not a micropython bug. |
Beta Was this translation helpful? Give feedback.
After some digging I found its a ESP32S3 chip bug which causes it to lose its ADC calibration register values during lightsleep().
There is a commit for esp_idf_4.4 to fix it: espressif/esp-idf@32afe6a
(essentially just adds a save/restore around the sleep)
Strangely my esp_idf_4.4 download doesnt have the fix, so I just added the save/restore functions to my esp32ext module (along with the gpio wake setup I needed to wake on a gpio on this MCU)