Analog Read Accuracy
Posted: Mon Nov 11, 2019 4:58 am
I just started dabbling in ESP32 with both MicroPython and Arduino IDE. I have a few different boards but the one I'm looking at now has an OLED and an 18650 LiIon battery. So I thought I'd start with something simple: display time from the internet (to test the wifi part of the board) and display the battery voltage, to test the board pins. Since the battery can get up to 4.2 V, I made a voltage divider so that the input pin would see less than 3.3 V, since that is the limitation. So after I built everything, I see the actual battery voltage is 4.08 V. The analog input is 3.187 V (divided by 100/128). But the ESP32 is telling me the pin is at 4095 (it should have been 3955). I spent about 30 minutes checking my setup and everything checked out. Then I started searching on the internet. In this forum, and other places, it is well known that the ADC is non-linear. So I have a couple of questions.
1) Is it still the case for the non-linearity? No firmware fixes or such? It seems odd that such a glaring problem would be allowed to remain.
2) I'll have to make a different voltage divider (and I was so proud of the one I already made ). What design point do I use? 3.05 V maximum? That is to say, when the battery reaches 4.2 V, the input to the ESP32 pin will be 3.05 V. So it would be a 100/138 division?
3) Does this issue also exist in the ESP8266? I bought some of those boards to play with as well.
I think I'll also rig up a variable resistor with a 3.3 voltage source and check the accuracy. But I was wondering what others are doing and if there is any additional advice.
By the way, if someone is going to redesign the board to include a battery, it seems like they should have made a provision to monitor the voltage/current. But that is a battle for another day. I think the board was about $8, not including the battery.
Thanks,
HH
1) Is it still the case for the non-linearity? No firmware fixes or such? It seems odd that such a glaring problem would be allowed to remain.
2) I'll have to make a different voltage divider (and I was so proud of the one I already made ). What design point do I use? 3.05 V maximum? That is to say, when the battery reaches 4.2 V, the input to the ESP32 pin will be 3.05 V. So it would be a 100/138 division?
3) Does this issue also exist in the ESP8266? I bought some of those boards to play with as well.
I think I'll also rig up a variable resistor with a 3.3 voltage source and check the accuracy. But I was wondering what others are doing and if there is any additional advice.
By the way, if someone is going to redesign the board to include a battery, it seems like they should have made a provision to monitor the voltage/current. But that is a battle for another day. I think the board was about $8, not including the battery.
Thanks,
HH