Go Down

Topic: NodeMCU (ESP8266) read real Vcc (Read 784 times) previous topic - next topic

BFoGvDo

Hi,

I'm working on a autonomous captor that is connected to a 9V battery. The battery is connected to the VIN Pin and the GND. I would like to calculate my battery percentage.
The problem is that when I get the Vcc by doing :

Code: [Select]

ADC_MODE(ADC_VCC);
ESP.getVcc();


I'm getting the internal voltage get by the ESP. I searched on google and a lot of people are getting the same issue, some are saying that you need to do an analogRead(A0) but this is generating a soft wdt reset on my board.. I would like to know if it's possible to get the voltage on the VIN pin.

Thanks a lot in advance.

Wawa

A 9volt smoke alarm battery is a poor candidate for powering a NodeMCU.
1) It can't keep up with the (~100mA) current draw.
2) More than half of the battery power is wasted in the regulator, because the ESP module on the board runs on 3.3volt.

Better use four AA batteries (4.5 to 6volt).

The code posted measures VCC, which is kept constant by the voltage regulator, and is therefore independent of battery voltage.

Connect a 680k resistor between the analogue pin of the board and battery(+).
Read the analogue pin, and divide the result by 102.4
Leo..

Go Up