# MOSFET N loss power battery calculation

I have a circuit to calculate my battery level using NodeMCU. I use this formula:

    float r1=10.0;   // resistor
float r2=2.0;    // resistor
temp = (analogvalue * 3.3) / 1024.0; // nodemcu works 3.3v and analogRead 1v
volt = temp / (r2/(r1+r2));


I have to power on/off different sensor to save power. When I calculate the battery level with the following schema I have a correct result: AnalogRead: 213 Battery: 4.12V

The problem is when I put a MOSFET to turnoff the battery calculator. I think that the MOSFET is like a resistor but I am not sure. With the following schema, I have the results: AnalogRead: 136 Battery: 2.63

Can somebody help me? Thanks!

• As @rdtsc said, I have needed a MOSFET P-Channel instead of N-Channel and it works perfectly. – b0rr3g0 Apr 26 at 5:58

Q1 is an N-channel enhancement-mode MOSFET, with intrinsic body diode. If you trace from 3v to the MOSFET, through it's body diode to R3, you'll see that the body diode will always conduct, giving you 3V - body diode drop into R3.

Furthermore, with NEMOS devices, the gate must be more positive than the source to turn it "on". So unless d5 is significantly more than 3v, it will be "open" or a very high value resistance.

You likely need a PEMOS device. These are turned "on" from the gate going lower than the source pin. The PEMOS body diode is also reversed, so will not conduct when the source is tied to 3V.

• ohhhh, I am sorry, this is a mistake at the picture. Really is a LIPO with almost 3.5-4.2V. I have modified it, the problem is that I need calculate the battery level. – b0rr3g0 Apr 22 at 8:15
• @b0rr3g0 Same problem, the body diode is always forward biased. – Unimportant Apr 22 at 8:21
• but... I have tested it in bradeboard and it's works correctly with N-Channel 2N7000 :( – b0rr3g0 Apr 22 at 9:34
• @rdtsc I have tested your solution and it works for me. Thanks a lot ;) – b0rr3g0 Apr 26 at 5:56