Analogue input Nodemcu

Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

Re: Analogue input Nodemcu#80444

By Bonzo
#80444
For LIPO measurement a 820K / 220K will work pretty well and not impose much extra drain on the battery.

Code: Select all`const int battery = A0;int input  = 0;void setup() {  Serial.begin(9600);  Serial.println ("Setup");}void loop() {  input = analogRead (battery);  Serial.println (input);  delay(1000);}`

R1 820K R2 220K input = 194-202 for 4.2V ( checked with multimeter )
Linear regulator = MCP1826S - Drop out 250mV typ so 3.55V min supply voltage?

200 = 4.2V
200/4.2 x 3.6 = 172

So I will need to change my battery at 172 which does not seem a very useful battery life.
I now have two second hand lipo battery packs with 4 cells and one pack has been running over a week so it is not to bad. I will check the voltage on the pack when the Nodemcu stops transmitting. Over the summer I will probably go back to the single battery with a solar panel which worked well. Due to charging problems with the lipo in the winter/cold I decided to go the full battery route.

no problem, just use a voltage divider between your battery and the external ADC.

Good idea schufti

Thank you all for the input and some very useful information I think.

Re: Analogue input Nodemcu#80450

By btidey
#80450 The 820K/220K suggestion was for a 1.0V type module like an esp-12. This means 4.2V would give 0.88V into the ADC for a reading of approximately 900.

You want to get fairly close to the max input of the adc to keep accuracy as high as possible.

For a NodeMCU there is already a 220K / 100K divider, So you could feed the battery in via a 150K resistor in series to the input. This effectively makes it a 370K / 100K divider. So 4.2V would give 0.89V or a reading of approximately 915.

For the usable battery voltage range with a good LDO with a drop out of around 100mV you can run the battery down to 3.4V. In fact you can even go lower as the regulator will just lower the output a bit and the ESP8266 will be OK with a supply of 3.2V. AT 3.3V the LIPO is pretty much exhausted.

Re: Analogue input Nodemcu#80451

By Bonzo
#80451 Thanks for the suggestion btidey and I had noticed the voltage was around 0.88 volts. I do not have many resistors at home but used my 360K one for R2 ( 1.28V ) and it also gave a more stable result.

The LDO specs said a typical dropout was 250mv and it will be interesting to see at what level my setup fails.

I will pick up a couple more resistors tomorrow. Through hole ones are getting used less and less at work now being replaced by SMD's. I did think about replacing the SMD ones on the board but decided it was best to leave well alone!

Re: Analogue input Nodemcu#80478

By Bonzo
#80478 Interesting results and the Nodemcu seems quite robust as I must have gone over 3.3V at some point.

Anyway I came home with a handful of resistors today and still do not quite have the correct ones!

Yesterday I tried 7.5K and 240K and had a value of 1024 which I had a feeling I was going over 3.3V although the voltage out of the potential divider was 3.2V

From a previous post I thought I had better go to a higher resistor range to help prevent drain on the battery.
I tried 75K and 240K and only had a value of 904
I moved onto 75K and 270K and now have a value of 924 which is probably good enough for what I want. The multimeter said these were actually 75.3K and 272K

I have just found a 300K and that is giving me a reading of 940

I suppose the internal impedance of the Nodemcu is having some effect?

Just thought I would check the voltage divider output:
Potential divider output 3.18V
Potential divider output 2.69V when connected to nodemcu

Got to go