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
Analog Read Accuracy
-
- Posts: 828
- Joined: Mon Jul 22, 2019 3:20 pm
Re: Analog Read Accuracy
This is a good read, and includes some examples of calibration. https://github.com/espressif/arduino-esp32/issues/1804
SAR is always going to be biased towards the ends of the scale, and the esp32 seems particularly insensitive there.
SAR is always going to be biased towards the ends of the scale, and the esp32 seems particularly insensitive there.
Re: Analog Read Accuracy
Search this on UTUBE
He gives a polynomial to linearise the analogs..
The best series of tutorials on the ESP32 I have come across
Tech Note 069 - Using the ESP32 ADC and some of its more advanced functions
He gives a polynomial to linearise the analogs..
The best series of tutorials on the ESP32 I have come across
Tech Note 069 - Using the ESP32 ADC and some of its more advanced functions
Re: Analog Read Accuracy
The start and end of ADC are not entirely accurate
https://randomnerdtutorials.com/esp32-a ... duino-ide/
https://youtu.be/yZjpYmWVLh8?t=81
https://randomnerdtutorials.com/esp32-a ... duino-ide/
Lolin did... on the D32 you can read Battery on Pin35Happy Hippo wrote: ↑Mon Nov 11, 2019 4:58 amBy 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.
https://youtu.be/yZjpYmWVLh8?t=81
Re: Analog Read Accuracy
the upper and lower end of analog input never seems to work for me either, i had a similar problem and I was able to get around it by changing my voltage divider to max out at 3v instead of 3.3. you will also have this problem on the low end, so try not to go under .3v,
R1 470ohm and R2 1kohm will give you 2.85v with a 4.2v source.
R1 470ohm and R2 1kohm will give you 2.85v with a 4.2v source.
Re: Analog Read Accuracy
This guy seems to have found a way around that.
https://qiita.com/fumi38g/items/bb728a0ee6f9094db4b9
https://qiita.com/fumi38g/items/bb728a0ee6f9094db4b9
Who is online
Users browsing this forum: No registered users and 64 guests