Hi All,
New here and not seeing any way to post code, apologies if I am getting up your noses already!
Anyway, I have a Wemos D32 ready to deploy, deep sleeps for most of the time but should check IO35 on wake-up to alarm in case of low battery. Seems that any time I read Vbatt I get full scale 4095 on the ADC? No errors, just 4095 irrespective of battery volts?
on the REPL I get...
>>> import machine
>>> adc = machine.ADC(machine.Pin(35))
>>> adc.read()
4095
Same result any time I call the adc.read() function in my code?
Is the ADC broken in the esp32 port at the moment or am I possibly messing with a fake board with no voltage divider on IO35?
Anybody else come across this?
Many thanks in advance
Garry
ESP32 ADC always reads 4095
Re: ESP32 ADC always reads 4095
The basic voltage range of the ADC is 0-1V. you can change that with an attenuator setting to about 1-3.2V if you need a wider range, you have to add your own voltage divider. The documentation about that for ESP32 is pretty sparse.
Setting the attenuator is something like:
Setting the attenuator is something like:
Code: Select all
from machine import Pin, ADC
pin=Pin(35, Pin.IN)
adc = ADC(pin)
adc.atten(ADC.ATTN_11DB)
Re: ESP32 ADC always reads 4095
Many thanks @Roberthh, that works well. I must crack out the multi-meter now and calibrate...
Garry
Garry
Re: ESP32 ADC always reads 4095
Tangentially...Note that I've made a start on the ESP32 documentation. You can view it or contribute via a pull request.
I've just created an issue: Need to improve ADC documentation. If someone could submit a PR that'd be great! Otherwise I'll get to it when I can.
Re: ESP32 ADC always reads 4095
It's not perfect but the ESP32 ADC QuickRef has improved. Well, it exists now.
We also need an ESP32 reference - then we can go into a little more detail about the ADC details. However the QuickRef and least touches on some of these points though it is meant to be terse.
We also need an ESP32 reference - then we can go into a little more detail about the ADC details. However the QuickRef and least touches on some of these points though it is meant to be terse.