battery level ESP8266

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
taku
New user
Posts: 8
Joined: 25 May 2018, 10:30

battery level ESP8266

#1 Post by taku » 24 Jul 2018, 13:41

Hello!
i want to measure the voltage level on the battery
connected as follows
to the pin, the ADC connected the output from the battery (where the plus was output through the 10K resistor and minus through the 5K resistor), then all these resistors are connected in one and the output is connected to the ADC) the controller itself flashed firmware ESP_Easy_mega-20180723_test_ESP8266_4096_VCC.bin, but the battery charge I did not see, I also noticed that on the ADC pin the voltage is 1.3V with a charged battery.
tell me what I'm doing not how I get the battery level.
If I add the device Analog input - internal
then the value is -1

Thank you

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: battery level ESP8266

#2 Post by Shardan » 24 Jul 2018, 13:56

It needs a bit more info.
Please can you give a schematic?
Are you using a "naked" ESP8266 or a nodeMCU / WeMOS?

Maybe a hint:
The ADC built into the ESP uses 10 bits over a range of 0...1 V.
10 bits gives 1024 output steps from 0 to 1023.
So one outupt step from ADC equals a voltage of 0,977 mV.

If you use a divider of 10K/5K on a blank ESP and a usual Lithium battery this can't work.
The fully charged battery has a voltage of around 3,7V.
10K/5K divides down to 1/3 this giving 1,23 V - far over the limit of the ESP's ADC.
If you use 20K/5K divider a charged battery will give 0.925 V, the ADC will show 947.
Be aware resistors have some tolerances so the value shown from the ADC may differ a bit.

For more info about ADC and handling out values see wiki:
https://letscontrolit.com/wiki/index.ph ... Converters
Regards
Shardan

taku
New user
Posts: 8
Joined: 25 May 2018, 10:30

Re: battery level ESP8266

#3 Post by taku » 24 Jul 2018, 14:08

i use naked ESP8266
chem i attachment
most likely you are right, I need to replace 10K at 20K
Attachments
P_20180724_150521.jpg
P_20180724_150521.jpg (1.23 MiB) Viewed 8179 times

taku
New user
Posts: 8
Joined: 25 May 2018, 10:30

Re: battery level ESP8266

#4 Post by taku » 24 Jul 2018, 16:16

i change resistor from 5k to 8.3K
and 5K to 26.7
in pin ADC i have 0.945V but in devices Analog value is -1.00

taku
New user
Posts: 8
Joined: 25 May 2018, 10:30

Re: battery level ESP8266

#5 Post by taku » 24 Jul 2018, 16:57

wheen i upgrade firmware from vcc to dev analog input show me current voltage.

Vic20
Normal user
Posts: 18
Joined: 29 May 2018, 11:51

Re: battery level ESP8266

#6 Post by Vic20 » 24 Jul 2018, 20:36

The ADC input of the ESP8266 is very high impedance (needs to draw an infinitesimally small amount of current) so you can get away with fairly large values of resistors in the divider network (the higher the better as these are directly across the battery and adding to drain).

Your original 15K total divider was having a constant drain on a 4v battery of 266 microamps .. quite a lot compared to the ESP8266 in deep sleep!

I am successfully running a li-ion battery sense network comprising a 120k and 390k resistor divider. This has a direct drain on the battery of approx 8 microamps. I suspect resistors even higher could be used.

taku
New user
Posts: 8
Joined: 25 May 2018, 10:30

Re: battery level ESP8266

#7 Post by taku » 26 Jul 2018, 08:12

that is, you to save battery consumption and to the port of ADS it is better to use high-resistance resistors

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: battery level ESP8266

#8 Post by Shardan » 26 Jul 2018, 16:03

That's correct.

The ESP8266 datasheet sadly doesn't say anything about ADC imput impedance.
It just gives a maximum currant for this pin of 50nA. As the max. voltage is 1V,
Ohm's law gives a resistance of 20 MOhm for the ADC pin, i assume it's even more.

So a voltage divider made of 5 MOhm / 1 MOhm should work.
20 MOhm in parallel to 1 MOhm gives already a small influence to the output,
but it is far below the tolerances of your resistors so that might be ignored without
issues.

For battery life this is the better way. It results in a current of about 0,67 µA
on the battery.
Regards
Shardan

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests