Electrical – Measure Li-ion battery voltage with an arduino 328p

arduinolithium ion

I try to monitore the battery capacity once every minute by reading the voltage with the ADC.

The arduino is powered by the battery through a boost converter (5V). I put a mechanical switch between the booster and the Vin so I can easily turn on/off the arduino.

I assume that wiring the input pin (Batt sense) directly to the battery (at 3.7v before the booster of course) will damage the arduino when I switch off Vin, so I decided to put a N-MOSFET switch controlled by the arduino which I activate just before measuring the voltage.

Can this work ? Am I doing something wrong ?

enter image description here

Best Answer

The N-channel MOSFET you have wired in will not work, because it's unlikely the Arduino can pull the gate higher than the Vgst of the MOSFET -- the Gate needs to be at least a volt and a half above the Source for it to turn "on." (This value of course changes depending on the specific MOSFET, but for discrete devices, you'll often see Vgst even higher than that.)

Meanwhile, a fully charged LiPo cell is 4.2V, and with 5V output, you only achieve 0.8V GS voltage.

Instead, you should hook up the input to your boot regulator to a 1 MOhm resistor, and then hook that to the voltage sense ADC input, and then short that to ground through a 4.7 MOhm resistor in parallel with a 100 nF capacitor. This will make a voltage divider that you can use to read the voltage. The leagage current though 3 MOhm is unlikely to ever be a problem for a circuit that's "on" (the loss in your boost regulator is much higher.)

The 1 MOhm resistor and the 100 nF capacitor work together to create a RC filter. The time constant for this filter is 0.1 seconds, so even if you read it every 10 seconds, you'd have a very accurate measurement. The reason you need the capacitor is because the AVR ADC requires a source impedance of 10 kOhm or less, and the 1 MOhm resistor clearly is more than that, so the capacitor provides a "reservoir" that the ADC can sample.

enter image description here