-->
Page 1 of 1

Analog to Digital Converters Overload???

PostPosted: Sat Apr 30, 2022 1:17 am
by Inq720
Have a question about the analog to digital converter in an ESP8266 WeMos for the A0 pin.
  1. I will be powering a WeMos ESP8266 with a 18650 battery shield. When plugged up, it'll be supplying 5V to the WeMos 5V pin. The WeMos uses its built-in converter to go from 5V to 3.3V for the ESP8266's use.
  2. The battery shield uses some converter of its own to maintain 5V output even though the 18650 goes from 4.1V to 3V as it discharges.
  3. Because of (#B) I can't use the ESP8266 feature of ADC_MODE(ADC_VCC);.
Can I run a wire from the positive 18650 battery terminal to the A0 pin and measure the battery voltage?... Electrically, is this a problem to power through the shield AND measure the voltage directly from the same battery on the shield?


powering.png


VBR

Inq

Re: Analog to Digital Converters Overload???

PostPosted: Sat Apr 30, 2022 11:40 am
by Bonzo
From memory a bare esp A0 input is ~1V when on a node mcu it is ~3V as it has a built in voltage divider.

I would either search the web for the maximum voltage input for your board or try with 1V input first and see what you get from the A0 pin. I would guess ~1V would be the max for your board.

You can then see what voltage divider you need but either way 5V is not a good idea!

Re: Analog to Digital Converters Overload???

PostPosted: Sat Apr 30, 2022 5:06 pm
by Inq720
Turns out that A0 pin on the WeMos is more tolerant of over voltage than the digital pins. I guess, the nature of measuring a variable voltage uses high impedance... like in a volt meter. Even a free Harbor Freight volt meter can tolerate really high voltage without frying all its innards. Using the wiring above in drain-test on the WeMos ending up working exactly as I had hoped.

  1. The 18650 cell started out at 4.2V.
  2. Supplying that 4.2V to A0 pin simply return a clipped value of 1024 for the analogRead() method, until it reached 3.3V.
  3. It battery lasted 2 hours, 45 minutes, with all but the last 10 minutes being below 3.3V.
  4. No smoke, no overheating, no warmth to speak of... no problem.

rundown.jpg

Re: Analog to Digital Converters Overload???

PostPosted: Tue May 03, 2022 9:33 am
by Inq720
Just to follow up...
Using the A0 pin to monitor the battery voltage of a battery on a separate Battery Shield supplying power to a WeMos / NodeMCU ESP8266.


By including a 100 KΩ resistor in-line between the A0 pin and the battery positive terminal, you can monitor the entire range (0 to 4.16V) of voltage coming from an 18650 LiIon cell using the following line:

Code: Select allvolts = (float)analogRead(A0) * 4.16 / 1024.0;


Here are the results of a drain test:
100Kohm test.png