ESP WROOM 02 with battery socket, does it need extra resistors to monitor 4.2v?

Hello,

I received this new module a few days ago, and the first thing I wanted to do was to measure the battery voltage, I can see next to the A0 pin 2 resistors, but I'm not sure if those are a volt divider.

I made myself a volt divider using R1 a 15k resitor and R2 a 4k7 resistor, but when I connect it to the A0 I get a very low reading: ~220. If I measured the A0 pin I had ~0.9v .. the battery was at ~3.95v.

As I was confused and pissed off because I couldn't get a good reading >:( I connected the + 3.95v to A0 pin and I got a reading of 1024, so it was saturated, if the board already had an volt divider, should the 3.9v be a little less than 1024 ?

Anyone around to have played with those boards, or do you have any documentation or schematic for this board ?

Any suggestion to make this volt divider work is appreciated!

Thank you.

Just try a single resistor (no divider) between battery and analogue input.
Experiment with the value until you get an A/D value of ~1000 with a 4.2volt source.
Leo..

There's a very short a datasheet available.

Interestingly no word about an analog in on that chip, just a TOUT pin which supposedly can be used to monitor a battery voltage.

Wawa:
Just try a single resistor (no divider) between battery and analogue input.
Experiment with the value until you get an A/D value of ~1000 with a 4.2volt source.
Leo..

I don't understand what is happening, I tried to do what you recommanded, to place just a resistor between the + and the TOUT pin, it took me a while to find an good value, and I dont know if there are any online calculators, like there is for the voltage divider, but the resistor that dropped the voltage from 4v to 0.9v was a 3.3M resistor. If I measured the voltage between the ground and through this resistor I had exactly 0.92v, this should have been good. But after soldering the resistor on the board, like in the photo bellow, the red wire is going to the A0 pin, the voltage is just 0.2v, I don't understand why this is happening. There is a voltage divider on the board ?

wvmarle:
There's a very short a datasheet available.

Interestingly no word about an analog in on that chip, just a TOUT pin which supposedly can be used to monitor a battery voltage.

I want to use this board to see how much time, hopefully years, it can run togheter with a small 5v soalar panel (69x150mm).

You shouldn't connect anything with output impedance of >about 10k to an analog input. 3.3M is too much: you won't charge up the port properly, which is why you get these erratic readings. As I said before: using a single resistor (or no resistor at all) you will ALWAYS get the full voltage at that port.

To get a voltage <3.3V at the A0 you need a voltage divider. For the ESP8266 (I assume the WROOM is the same), the ADC goes from 0-1.06V for 0-1023 reading. You have to reduce your voltage to about 1/4. So Vcc - 10k - A0 - 3k3 - GND will work fine for that. But then you also have a significant current leakage of 0.25 mA through those resistors - a waste when you're on battery power.

Instead on the ESP8266 modules you can use the ESP.getVcc() command to read the voltage on the Vcc pin. To make this work, you also have to add ADC_MODE(ADC_VCC); to the top of your sketch, and disconnect A0/TOUT. Note that you can not use the analog pin for anything else when switching it to read Vcc.

wvmarle:
...To get a voltage <3.3V at the A0 you need a voltage divider. For the ESP8266 (I assume the WROOM is the same), the ADC goes from 0-1.06V for 0-1023 reading. You have to reduce your voltage to about 1/4. So Vcc - 10k - A0 - 3k3 - GND will work fine for that. But then you also have a significant current leakage of 0.25 mA through those resistors - a waste when you're on battery power.

First time I used a divider using 15k and 4k7 resistors, with those values the voltage drop was way to high, as the reading on the A0 pin was ~200 .. the voltage was somewehere around 0.22v... so this is why I tried other methods.

I will make a voltage divider using 10k and 3k3 as you suggested and report back.

It seems that your module has some circuit on it that scales the ADC to a 0-3.3V full scale.
So try switching those two resistors: Vcc - 4k7 - A0 - 15k - GND.

wvmarle:
It seems that your module has some circuit on it that scales the ADC to a 0-3.3V full scale.
So try switching those two resistors: Vcc - 4k7 - A0 - 15k - GND.

Will try that too tomorrow, right now I made a photo with the 2 resistors that I though ware used as a volt divider ...

wvmarle:
...using a single resistor (or no resistor at all) you will ALWAYS get the full voltage at that port.

True for most Arduinos, but I think there is already a voltage divider on that board.
A single resistor adds value to the top resistor of the divider.

I guess a clear picture of the divider values and board traces could help.
Leo..

Indeed there must be something at that analog port to bring the range to 3.3V but I'm not sure what it is - a plain voltage divider sounds like a terrible idea to me, as the pretty low impedance needed for it not to mess up the analog port, messes up just about any input signal. Haven't seen any clear schematics, and the NodeMCU board is too dense to easily do trace following (and many components are unmarked anyway).
The input impedance of the analog port is supposed to be in the tune of 60M or so. Would require an OpAmp buffer or so.

sibianul:
Will try that too tomorrow, right now I made a photo with the 2 resistors that I though ware used as a volt divider ...

That appears to be s a 224 (220k) and a 010 (1 Ohm) in series. There is indeed a via connecting to the 010 - wonder where that is leading to. The other end of the 010 is apparently linked to the top plane of the board, most likely GND or Vcc (3.3V).
That doesn't really make sense, as the values are so far apart that you get nearly 0V or Vcc (depending on what that plane is connected to) on that via at all times. So I wonder what I'm missing there.

Can you measure that 010 resistor.
Leo..

Just a quick reply as I don't feel very well, I just came to my office for a few minutes, it seems the resistors are ~17k and ~8k ?

It's not reliable to measure resistance when it's on the PCB as you have no idea what possible other channels the current has.

Measuring that resistor with reversed polarity may give you very different results!

wvmarle:
It's not reliable to measure resistance when it's on the PCB as you have no idea what possible other channels the current has.

Measuring that resistor with reversed polarity may give you very different results!

Might tell you if that is a 1ohm resistor or not.

Never seen a resistor with a negative value.
Could it be that OP measured with the module powered on.
Leo..

I did a search on some "number to value" converter web site and it said 010 an invalid marking...

Also no negative values, but different values due to different parallel current paths (apparently including a diode).

I got an answer on esp8266.com forum with a link to a blog where there are more details about this board. It seems the R1 is 220k and R2 is 100k, with those values it seems the A0 pin can only measure up to 3.3v .. I don;t get it, what's the point of measuring up to 3.3v when the battery maximum is 4.2v ? This is a battery powered board, isn't it logical to be able to measure the battery voltage with it ?

What you suggestions are regarding on what modifications I can make to be able to measure up to 4.2v ? Is there anything simpler than just replacing the R2 resistors ? I will look over to see what resistors do I have around 68k value, as this is what the voltage divider calculator reported to be the R2 value, to be able to measure up to 4.2v

Any more advices are welcome.

Thank you

A0 is not meant to measure battery voltage directly, it's to read the analog out of sensors (which have an output impedance low enough to not be affected by the 10 µA leakage due to this resistor divider).

Knowing these values: if adding a 100k resistor between batter and A0 you would be able to measure up to 4.2V. For safety, I'd use 120-150k there - max voltage 4.4-4.5.

I placed an 100k resistor inline and now I finally have a good reading :smiley:

Thanks.