-->
Page 1 of 2

How to interpret ESP.getVcc() readings

PostPosted: Mon Feb 15, 2016 8:14 am
by Andrew Grande
Hi, so I did ADC_VCC and get analog reads of the esp voltage. Running on a 3.7 lipo battery, dev board. Readings divided by 1000.0 look realistic? I had 2.36 value via API, but the voltmeter shows 3.78 for the battery.

Should I be scaling internal readings to the 3.3v standard? I just couldn't find much docs on this method.

Re: How to interpret ESP.getVcc() readings

PostPosted: Tue Feb 16, 2016 7:41 am
by Drum
If you do this with most modules it will not work correctly without a resistor divider as the Max input for ADC is 1V. I have been playing with this for a while, and it does work. I set one up last weekend to see how long a 5000 mah Lipo would last. Just under 60 hours till it stopped transmitting. If you don't do it correctly, it can make wild swings over time. Looks almost like an earthquake graph.

Without more information, what board, exactly how connected, it really isn't possible to say much more. If you are not using a resistor divider, ask Google for a Resistor divider calculator.

Re: How to interpret ESP.getVcc() readings

PostPosted: Tue Feb 16, 2016 12:50 pm
by Andrew Grande
Thanks for the info, @Drum. Let me confirm I understand. The board is one of those NodeMCU types with (tons of) additional regulators, etc, so I don't understand the requirement for an additional divider. I'm feeding the battery into Vin/Gnd (yes, I understand in case of a bare esp12e/f chip we would need more to ensure a stable supply).

The ESP.getVcc() reports whatever internal math it did, how is adding additional resistors between the supply battery and Vin affecting it? Is it at all?

I could probably just calibrate values reported by the voltmeter and this API over the lifetime of a battery charge and map them to a working range for reporting. I am wondering, though, if my multimeter sucks badly (I'm sure it does) and/or the Esp.getVcc() has lots more going on.

If that matters, I'm also hooking up an additional attiny85 board + analog sensor to esp12's 3.3 volt line, not sure about the effect (I need a free ADC pin for the API call to work, and still read my analog sensor).

Re: How to interpret ESP.getVcc() readings

PostPosted: Fri Feb 19, 2016 8:18 am
by Drum
Okay, there are 2 problems with doing this on a Node MCU.
First, while the ESP8266 should be able to measure voltage on the VDD pin of the chip, it is limited to 1.8 to 3.6 V, and if you are using that method, you are measuring the voltage after is has gone through the voltage regulator, not from Vin pin.

Second, on the ADC (A0) pin the schematic shows a resister voltage divider which brings the voltage down to (V * 0.3125) and as the ESP8266 ADC pin can only handle up to 1 V, the max input for the A0 pin is 3.3V. So putting a Lipo on that pin (could be 4.2v or more) is not going to work well, I have accidentally (reversed resister divider) exceeded the 1 V limit and the graph looked like an earthquake graph. Up and down, min to max until I disconnected it.

Someone with a better understanding of electronics can look at the schematic and let you know if you can use another resister divider before the A0, but I think that is iffy. Might be possible though. I try to shoot for 10 V = 1 V to make it easier to calculate.

You could try it in the external board, or try something like the adafruit ina219 breakout board which is i2c and measures current and voltage.

I like the Node MCU as a first introduction to the ESP8266, or even for use with a wall wart, but not so much for batteries. I don't think the voltage regulator is efficient enough and if i read the datasheet correctly it wants 4.75 to 10 V. I had a lot of problems using one on a 3.7 V Lipo. So I use them with a wall wart . For testing on batteries I am using the Olimex Wifi-Mod-esp8266 boards, they are between the ESP12 and Node MCU. No buttons, voltage regulator or USB port, runs out of the box (all pullups / downs hard wired) just jump GPIO 0 to ground to program. They have a light that stays on even in deep sleep, but nothing is perfect. I use a firmware which allows you to browse from the web interface to upgrade, so I only have to connect it to the USB adapter once, and it can stay where ever it is after that. Really easy... (ESPEasy) ;-)