The ESP8266-12E is a low power, blazing fast, MCU with WiFi capabilities making it the best option for small robotics projects. I am trying to measure the voltage of a 3.7v lipo in order to determine the battery life of the robot. The battery, when fully charged, is 4.2v but my regulator drops out at less than 1v. I obviously can not pass the 4.2v from the battery directly into the MCU's onboard ADC, and I know I need a resistor in order to drop the voltage to a certain level under 3.6v (it's maximum voltage rating) and generate a percent on that new scale, but to calculate the value of said resistor, I need to know how much current the onboard ADC for the ESP8266-12E draws.

How much current does the ESP8266-12E's onboard ADC draw?

This is what I came up with: This should allow me to drop the voltage from the maximum possible 4.2v of a fully charged lipo down to solid 3v. I also added a MOSFET to keep the voltage divider from constantly draining the battery. Anyone know if this will work alright? I am using a barebone ESP that I purchased here. @mkeith, I remember seeing somewhere on a datasheet that the ADC can take up to the maximum voltage of the unit itself, which is 3.6v. I could always redo my calculations and drop the voltage down to under 1v to be on the safe side. I just don't want to lose any resolution in my final percentage if I don't have too. I trust this community more than I trust some poorly translated Chinese PDF.

• In this case, I think the easiest thing might just be to use a voltage divider to cut the battery voltage in half. So, use 100k 1% resistors to make your divider. If you need to save power, you can use a FET to disconnect the divider from the battery when you don't need it. Just connect the divider when you need to sample the voltage. Mar 21, 2017 at 3:41
• @mkeith - Cutting it in half might not work in all cases. earlier, ESP adc used to work on 0-1 V range. And most of them available in market still use the same voltage range. Probably the fancy ones like node MCU and similar might have made extra circuitry to enable 3.3 V but it'd be worth making sure for the exact model OP is using. Mar 21, 2017 at 6:05

The raw ESP ADC has a full scale range of 0-1V, so you would need a divider of about 4.2:1 to capture the 4.2V input. Since you're switching it, the resistance value is not critical and can be made reasonably low.

Perhaps something like this:

simulate this circuit – Schematic created using CircuitLab

The ADC sees a source impedance of about R2||R3 = 11.5K when measuring (15K when off, but that doesn't matter) and the 0-1V ADC input range translates into 0-4.32V. You might want to make the divider ratio a bit more conservative since the ADC in that part is so very loosely specified.

This circuit draws less than 110uA when measuring and almost nothing when 'off'.

Using just a resistor will not work.

You need to use a resistor divider to bring the voltage down to a range the device can accept. However, I am assuming you need to do that in a way that will not consume much battery current. As such you will need large resistors and possibly some kind if MOSFET switching circuit to turn it off when not needed as @mkeith suggested in the comments. If you use the latter you will also need to be careful that the signal line does not go over Vcc when the switch is closed.

• Have you ever tried this before? It does not look like it would work to me. The DC bias point of the capacitive divider node is not well defined. It will rely on leakage currents of D1, and input impedance (or leakage) of the ADC. Mar 21, 2017 at 3:42
• @mkeith I have but I must admit, not with such low currents. And the diode was an afterthought. I thought abut your suggestion of the R divider with a switch first too but remembered this circuit. Unfortunately the circuitlab simulator does not delve into it that far. Mar 21, 2017 at 4:02
• @mkeith I decided to remove it. Mind you.. "Just connect the divider when you need to sample the voltage" isn't so easy either when you need to protect the pin. Bottom side switch wont work, and top side is out of range of the mcus output pin. Mar 21, 2017 at 4:14
• yes, it is not so easy. I believe you will need two transistors. A high-side PMOS with a pullup and an NPN or NMOS to drive the PMOS gate low. Mar 21, 2017 at 16:20

You should realize that ADC pin also has got an internal resistance which is ~ 220K as per my calculation. So if you use large resistors like R1=220k, R2=100K for the voltage divider then you will see quite significant difference in drop while you have connected the middle pin (across R2) to ADC pin and while its not connected to that pin. So you should take that into account as well while you are calculating the resistors for voltage divider