0

Inaccurate Lipo battery voltage measurement on feather?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Inaccurate Lipo battery voltage measurement on feather?

by IoTAll on Tue Jul 16, 2019 3:21 am

Hi!

I a using a M0 Atwinc WiFi feather and I have a 2500mAh battery connected to it.

I have let the battery charge for the whole night, the feather not doing anything.

I measure the battery level at the pin A7 and apply the formula given in the tutorial to get the battery charge level.

The voltage stabilizes at 4,02 volts and not 4,2 as indicated for a full charge.
Is this normal? If yes do you know what is the reason for this drop of voltage of 0.18?

Thank you!

IoTAll
 
Posts: 133
Joined: Wed May 31, 2017 6:34 pm

Re: Inaccurate Lipo battery voltage measurement on feather?

by adafruit_support_bill on Tue Jul 16, 2019 6:28 am

What is the battery voltage measured with a multimeter? There are several factors that could explain why the reading is different from what is expected:

1) Resistor tolerances - Normal manufacturing variability means that the actual values of the resistors in the voltage divider on the board will vary somewhat from the rated value.
2) Voltage reference tolerance - Similarly, the actual analog reference voltage may vary slightly from the specified 3.3v due to manufacturing variations in the voltage regulator.
3) ADC errors - The Feather's internal Analog to Digital Converter will have some non-linearity and quantization error.
4) Charger accuracy - The Vreg charge voltage for the charge controller may differ slightly from the spec.

Individually, these errors are usually small. And on average they tend to at least partially cancel each other out. But sometimes the tolerances stack up to create a significant error.

However, in most cases, the important thing is that the measurement is repeatable. If you have repeatable measurements - and a trustworthy reference (e.g. a multimeter) you can calibrate your system for accuracy. https://learn.adafruit.com/calibrating- ... -calibrate

adafruit_support_bill
 
Posts: 74337
Joined: Sat Feb 07, 2009 10:11 am

Re: Inaccurate Lipo battery voltage measurement on feather?

by IoTAll on Mon Aug 19, 2019 1:56 pm

OK clear, thank you very much for the detailed explanations!

IoTAll
 
Posts: 133
Joined: Wed May 31, 2017 6:34 pm

Re: Inaccurate Lipo battery voltage measurement on feather?

by boroko on Wed Aug 21, 2019 3:16 am

Having a similar problem with a Feather M0 (bunch of them actually) right now. Trying to calibrate a shut down before the battery goes into cut-off. I don't care about absolute accuracy, but I do need to need to prevent the battery disconnecting as it will not restart the charge without detecting the battery (which of course doesn't happen when the battery disconnect opens). I have a USB cable with switchable power and have been using it to find the actual cut-off of the battery and set the software to shut down before it happens. One symptom that I'm seeing is that when the battery is near the lower limit, and not externally powered, the Feather is not detecting the same voltage as when it's powered. To explain, I'm letting the battery drift down to near the cut-off, (3v monitored with a meter) and the serial is reading around 3.52v. As soon as USB power is switched on, the reading drops to within 0.1v of the meter. If I leave the USB power off, the ADC never drops below the 3.5v. This is causing me some great consternation and is a bit of an embarrassment trying to explain to my customer that he needs to open the device and bump the battery to get it to work again. If it does go into cut-off at the battery, even the shortest application of voltage is enough to reconnect and get it going again. Still not a solution though. Any thoughts?

boroko
 
Posts: 44
Joined: Mon Jul 06, 2015 2:41 am

Re: Inaccurate Lipo battery voltage measurement on feather?

by adafruit_support_bill on Wed Aug 21, 2019 6:27 am

One symptom that I'm seeing is that when the battery is near the lower limit, and not externally powered, the Feather is not detecting the same voltage as when it's powered. To explain, I'm letting the battery drift down to near the cut-off, (3v monitored with a meter) and the serial is reading around 3.52v. As soon as USB power is switched on, the reading drops to within 0.1v of the meter. If I leave the USB power off, the ADC never drops below the 3.5v.

This happens when the battery voltage approaches the level of the analog reference voltage (3.3v). At that point, the regulator can no longer regulate and the reference voltage ends up being somewhat less than the actual battery voltage. So any voltage calculation assuming a 3.3v scale is wrong.

A similar phenomenon can be seen in many multimeters. When the batteries get low, the meter starts reading high.

adafruit_support_bill
 
Posts: 74337
Joined: Sat Feb 07, 2009 10:11 am

Re: Inaccurate Lipo battery voltage measurement on feather?

by boroko on Wed Aug 21, 2019 4:50 pm

Ahh, thank you Bill. Hadn't reset my mental reference after moving from 5v to 3.3v. I'll dig in to see if lowering the reference is practical.

boroko
 
Posts: 44
Joined: Mon Jul 06, 2015 2:41 am

Re: Inaccurate Lipo battery voltage measurement on feather?

by boroko on Thu Aug 22, 2019 5:25 am

Help me along here... if the knee of a LiPo discharge curve is in the 3.3 v area, how would you know from the divider and ADC when it has hit that area?
The ones I'm using are ID: 1578, 500mA ones. Having not found the curve from this specific battery, I'm guessing. Since the ADC and divider is only reliably reading down to ~3.5v, can you suggest a good way to measure it and a good time to apply a shut-down?

From generic curves, it looks like 3.4v is just entering the knee and 3.5v is in the middle of the useful charge range.

This application has pretty constant current drain with a flashing LED and an occasional SD card write that would dip the battery if that helps.

Thanks

boroko
 
Posts: 44
Joined: Mon Jul 06, 2015 2:41 am

Re: Inaccurate Lipo battery voltage measurement on feather?

by adafruit_support_bill on Thu Aug 22, 2019 6:33 am

Most of the published LiPo curves floating around on the web are for RC applications at high discharge rates. At discharge rates more typical of electronics projects, there is less voltage drop due to internal resistance of the cell, so the overall curve is a bit higher. 3.5v would tend to be just above the knee of the curve.

To get down below that level, you would need to use a different analog reference. The Feather boards do not have an external AREF pin. But many processors have internal analog references that can be selected in code: https://www.arduino.cc/reference/en/lan ... reference/

adafruit_support_bill
 
Posts: 74337
Joined: Sat Feb 07, 2009 10:11 am

Re: Inaccurate Lipo battery voltage measurement on feather?

by boroko on Thu Aug 22, 2019 7:48 pm

Hi Bill,
Thank you for taking the time to offer these answers. I might be especially dense on this issue, so you may have to spell it out for me. If I'm using a Adafruit Feather M0, and an Adafruit battery, and it is presented that the Feather has a divider so that you can measure the battery, What am I missing about doing that?

bo

boroko
 
Posts: 44
Joined: Mon Jul 06, 2015 2:41 am

Re: Inaccurate Lipo battery voltage measurement on feather?

by adafruit_support_bill on Thu Aug 22, 2019 8:25 pm

If you are using an M0, you can select the AR_INTERNAL2V23 internal 2.23v reference. That should let you measure all the way down to the protection circuit cutoff voltage.
https://www.arduino.cc/reference/en/lan ... reference/

adafruit_support_bill
 
Posts: 74337
Joined: Sat Feb 07, 2009 10:11 am

Re: Inaccurate Lipo battery voltage measurement on feather?

by boroko on Thu Aug 22, 2019 9:24 pm

Thank you Bill.

boroko
 
Posts: 44
Joined: Mon Jul 06, 2015 2:41 am

Re: Inaccurate Lipo battery voltage measurement on feather?

by boroko on Mon Aug 26, 2019 3:12 am

Hi Bill,

I'm looking at https://learn.adafruit.com/adafruit-feather-m0-radio-with-rfm69-packet-radio?view=all#power-management
and this is what I see:

Code: Select all | TOGGLE FULL SIZE
Measure Battery .....
#define VBATPIN A7   
float measuredvbat = analogRead(VBATPIN);
measuredvbat *= 2;    // we divided by 2, so multiply back
measuredvbat *= 3.3;  // Multiply by 3.3V, our reference voltage
measuredvbat /= 1024; // convert to voltage
Serial.print("VBat: " ); Serial.println(measuredvbat);


My understanding is that with Vref at default (3.3v), the A/D will divide the analog read (0v-3.3v) by 1024 resulting in 0.0032226v per count.
With the dual 100k divider, a full LiPo of 4.2v, the A/D will see 2.1v and read approximately a count of 652.
With a battery approaching cut-off (3.0v), after the divider, the A/D will see 1.5v and the count will be ~465.
The formula (*2) above takes a number in the range of 652 to 465 and doubles it giving a float variable in the range of 1303 - 930.
The next step multiplies that by the Vref (3.3) and gets a range of 4300 - 3069.
The last step divides that by 1024 and gets a voltage of 4.2v - 3.0v

Can you please further explain what I'm missing on why I can't read down to 3.0v with a 3.3v Vref?

boroko
 
Posts: 44
Joined: Mon Jul 06, 2015 2:41 am

Re: Inaccurate Lipo battery voltage measurement on feather?

by adafruit_support_bill on Mon Aug 26, 2019 5:56 am

Can you please further explain what I'm missing on why I can't read down to 3.0v with a 3.3v Vref?

Because your actual Vref is no longer at 3.3v if your primary supply voltage drops below 3.3v.

With a battery approaching cut-off (3.0v), after the divider, the A/D will see 1.5v and the count will be ~465.

With the battery at 3.0, your analog reference will be slightly below that - say 2.8v. The A/D will still see 1/2 the battery voltage or 1.5v. And given a full-scale voltage reference of 2.8v, the raw counts will be about 549.

adafruit_support_bill
 
Posts: 74337
Joined: Sat Feb 07, 2009 10:11 am

Re: Inaccurate Lipo battery voltage measurement on feather?

by boroko on Mon Aug 26, 2019 6:20 am

Hope the question didn't sound snarky, I just couldn't see the issue. Didn't even occur to me about the voltage supplied being below the reference, Duh!
Just to close this questioning loop, I can see now that I will not have a problem with running the lower reference (2v23) since the voltage seen by the A/D after the divider is only going to be 2.1v.
The only other issue that I might have to adjust for is that I also monitor external voltage of up to 16v. It doesn't need to be terribly accurate as it's only identifying if external power is available. I should be able to adjust the divider for that input and get it close while still using the 2.23v reference.
For future reference, is there any issue with running over the Vref? By that I mean if I were checking a voltage that maxed out the count on the A/D, my suspicion is that you would just loose the ability to measure above the max count and not damage anything. Please correct me if I'm wrong.

I appreciate the help pointing out what should have been obvious.
bo

boroko
 
Posts: 44
Joined: Mon Jul 06, 2015 2:41 am

Re: Inaccurate Lipo battery voltage measurement on feather?

by adafruit_support_bill on Mon Aug 26, 2019 7:50 am

For future reference, is there any issue with running over the Vref?

It is not a problem to exceed Vref. But you should not exceed Vdd. If using the 2.23v reference, voltages between 2.23 and 3.3 will be over-range, but not harmful.

adafruit_support_bill
 
Posts: 74337
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.