How to isolate voltage divider both from power and ground ?

Thread Starter

tsvetan.filev

Joined Jan 15, 2021
6
Hi everyone.

I'm using this method https://jeelabs.org/2013/05/17/zero-powe-battery-measurement/ to make esp32 measure it's own battery voltage. It measures fine but there is a small problem. I put the esp32 in hibernation mode with disabled IO periphery according to this https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/#esp32-hibernation-mode. In this mode the GPIOs go to undefined state and have about 1.9 V (because of IO diod protections) to ground and this drains the battery as there is voltage between ADC and ground. It seems I need two transistors in order to isolate the ADC port from both "+" and "-". So is there a way to attach two transistors to a single GPIO or may be use second GPIO ?

Here is what I do:
1. I uploaded a program that does some stuff and also measures the voltage
2. Once the program ends it puts esp32 in hibernation which disables everything except the low power RTC.
3. I noticed that this workflow drains the battery much faster then without resistors.
4. While in sleep I measured the voltage between ADC pin and ground and found 1.9 V. This drains the battery through the second resistor from the voltage divider as the first one is isolated by the FET.
5. My conclusion is that it is the ADC pin that causes the leak. Another option is that the actual ADC procedure to be very consuming but I doubt.

Any ideas ?
 

crutschow

Joined Mar 14, 2008
27,449
Please post a schematic of your exact circuit.
I don't understand exactly what's happening.
Why doesn't the circuit in your first reference block that current?
 

Wolframore

Joined Jan 21, 2019
2,317
You need a pull down to shut the NMOS off. It can be high value since switch time isn't a concern. Try 100K from gate to ground.
I would put the NMOS below the bottom resistor for better performance.

1610728665116.png
 

BobTPH

Joined Jun 5, 2013
3,500
Put a pull down on the gate to keep it off.

I don’t think that is the best placement of the MOSFET though.

Bob
 

BobaMosfet

Joined Jul 1, 2009
1,823
Hi everyone.

I'm using this method https://jeelabs.org/2013/05/17/zero-powe-battery-measurement/ to make esp32 measure it's own battery voltage. It measures fine but there is a small problem. I put the esp32 in hibernation mode with disabled IO periphery according to this https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/#esp32-hibernation-mode. In this mode the GPIOs go to undefined state and have about 1.9 V (because of IO diod protections) to ground and this drains the battery as there is voltage between ADC and ground. It seems I need two transistors in order to isolate the ADC port from both "+" and "-". So is there a way to attach two transistors to a single GPIO or may be use second GPIO ?

Here is what I do:
1. I uploaded a program that does some stuff and also measures the voltage
2. Once the program ends it puts esp32 in hibernation which disables everything except the low power RTC.
3. I noticed that this workflow drains the battery much faster then without resistors.
4. While in sleep I measured the voltage between ADC pin and ground and found 1.9 V. This drains the battery through the second resistor from the voltage divider as the first one is isolated by the FET.
5. My conclusion is that it is the ADC pin that causes the leak. Another option is that the actual ADC procedure to be very consuming but I doubt.

Any ideas ?
You need to turn your ADC off in low-power mode, and only turn it on when you go to test the battery, then turn it back off.
 

djsfantasi

Joined Apr 11, 2010
7,763
Why not use a P-channel MOSFET to turn on power to the voltage divider, and an N-channel MOSFET to turn the P-channel one on?
If there’s leakage between one of the ADC inputs and both (or either) ground and the positive voltage, use an N channel MOSFET to isolate the ground connection AND drive a P channel MOSFET to isolate the positive source.
 

Thread Starter

tsvetan.filev

Joined Jan 15, 2021
6
@crutschow

Please post a schematic of your exact circuit.
I don't understand exactly what's happening.
Why doesn't the circuit in your first reference block that current?


This is my circuit https://jeelabs.org/wp-content/uploads/2013/05/Screen-Shot-2013-05-15-at-13.40.541.png
I think that the leakage comes from AIO through bottom resistor to ground because I measured about 1.9V between AIO and ground when ESP32 is in hibernation i.e. GPIO periphery is off.

@Wolframore

You need a pull down to shut the NMOS off. It can be high value since switch time isn't a concern. Try 100K from gate to ground.
I would put the NMOS below the bottom resistor for better performance.


I thought that the idea of this circuit is to have the FET off and only when GPIO is "1" to have it on. Why would I need a resistor.
Do you think that putting NMOS bellow bottom resistor is fine ? Because this would solve the issue I guess.

@BobTPH

Put a pull down on the gate to keep it off.
I don’t think that is the best placement of the MOSFET though.


Same question as for Wolframore. So you think that the leakage comes from not having fully FET off ?

@BobaMosfet

You need to turn your ADC off in low-power mode, and only turn it on when you go to test the battery, then turn it back off.

Yes this is what I do. It actually samples for some short period of time (depending on settings) and then executes a callback with the result. When the device goes to hibernation it is completely powered off.

Instead of a mosfet, use a 4N35 opto-isolator. It has 100% transfer on the base,. This is a technique I've used successfully in projects to measure bat-voltage into an ADC.

Is there any difference in my case between FET and 4N35. I guess I can put two or may be only one after bottom resistor ?

@John P

Why not use a P-channel MOSFET to turn on power to the voltage divider, and an N-channel MOSFET to turn the P-channel one on?

Sounds good can you draw a circuit pls ?

@djsfantasi

If there’s leakage between one of the ADC inputs and both (or either) ground and the positive voltage, use an N channel MOSFET to isolate the ground connection AND drive a P channel MOSFET to isolate the positive source.

Sounds good can you draw a circuit pls ?


So my question at the end of the day is "How to completely isolate the divider and only turn it on when I measure ?"
 

Wolframore

Joined Jan 21, 2019
2,317
The others are right you need a PMOS switched with an NMOS, It stops 12V at the IO pin when off.

Yes I believe the MOSFET is not shutting off... if it's working the way it is which is doubtful since your MOSFET isn't biased correctly try the pull down but don't move it.
 

John P

Joined Oct 14, 2008
1,903
OK, here's what I was thinking of, drawn with my ancient copy of OrCAD. The transistors can be any small-signal MOSFETS; R1 is a large value, maybe 1M, to make sure Q1 turns off entirely; R2 and R3 form your voltage divider.

Clipboard01.jpg
 

John P

Joined Oct 14, 2008
1,903
Are you planning to build this by hand once, or is it going to be on a circuit board? If it's hand built, you certainly don't want to use surface mount packages. Look for TO-92 components.

I don't think your transistor choices are very good. The BSS127 is rated to 600V, and you certainly don't need that. Also it has a gate threshold of up to 4.5V, which you may not be able to reach. Look at the 2N7002, which is kind of a standard for small MOSFETs, or something similar. But for the P-channel transistor, it does seem as if small P-channel MOSFETS with low resistance are hard to find. You'd have to decide how low the resistance needs to be in order not to affect your voltage divider. Maybe a power transistor is necessary, but the IRF9640 is another one with a gate voltage of up to 4.0. Perhaps it's better to use a plain old PNP transistor, like the 2N3906. A 10K base resistor would probably be OK.
 

alex.will

Joined Jan 13, 2021
16
use a BSS138 FET and 2 10K resistor and the center pin of voltage divider to your ADC channel and read analog voltage and control using program, case solved
 
Top