Is this connection right?
Its for ESP32 to measure the voltage of a 18650 battery.
-
1\$\begingroup\$ Your MOSFET is upside down (drain and source switched) and the wrong type. \$\endgroup\$– virCommented Oct 21 at 2:54
-
\$\begingroup\$ Is VMeasure supposed to be an output? If so, then shouldn't your FET be a P-channel? \$\endgroup\$– ColinCommented Oct 21 at 2:58
2 Answers
No, it is not right. There are so many mistakes lets just start over.
I believe the circuit you're looking for is this:
simulate this circuit – Schematic created using CircuitLab
M1 is a PFET. When EN is low Q1 is off so M1's gate is pulled to VBAT and M1 is off. No current flows anywhere (except leakage).
When EN is high, Q1 turns on. This pulls the gate of M1 low, turning it on. Your voltage divider now works normally.
Note that if VBAT is greater than the max negative gate voltage of M1 you need an additional zener diode and resistor to Q1 to limit how low the gate can go.
-
\$\begingroup\$ What's an appropriate value for R4? \$\endgroup\$ Commented Oct 21 at 5:07
-
\$\begingroup\$ @SimonFitch It mostly depends on how fast you want this sensor to switch. Anything below a couple Mohm will work really. \$\endgroup\$ Commented Oct 21 at 12:46
-
\$\begingroup\$ If power drain is a concern then maybe Q1 should be an N-channel MOSFET? \$\endgroup\$ Commented Oct 21 at 18:36
Realistically you don't need to go this complex for a 18650 battery. Their self-discharge is about 50 µA. If your sleep current is significantly below this, it has little effect on the battery life.
Use a megaohm resistor paired with a capacitor, and you get down to microamps of load current. You can even use 10 megaohms if needed. The capacitor provides buffering so that the voltage doesn't drop during ADC sampling. The capacitor will then recharge slowly, assuming you only take battery measurements a few times per second.
simulate this circuit – Schematic created using CircuitLab
Even if you go with the MOSFET, it is a good idea to add the capacitor. Otherwise you'll require a long ADC sampling time to avoid voltage drop with the 100 kilo-ohm resistor divider.
Check the input voltage range of the ADC, for most ESP32 models it is 0 to 1.1 V. Your original values would give 1.3 V when the battery is at 4.2 V.