0
\$\begingroup\$

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: Schematic 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.

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – mkeith Mar 21 '17 at 3:41
  • \$\begingroup\$ @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. \$\endgroup\$ – Whiskeyjack Mar 21 '17 at 6:05
0
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – mkeith Mar 21 '17 at 3:42
  • \$\begingroup\$ @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. \$\endgroup\$ – Trevor_G Mar 21 '17 at 4:02
  • \$\begingroup\$ @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. \$\endgroup\$ – Trevor_G Mar 21 '17 at 4:14
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – mkeith Mar 21 '17 at 16:20
0
\$\begingroup\$

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

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.