Battery percentage gone wild [SOLVED]
-
what is the reference voltage of the ADC ? You will get negative batteryPcnt values for sensorValue lower than 837, what happens with the batteryPcnt values ? maybe thaey are treated somewhere as unsigned ? You say You use voltage divider but I don't see that your code is handling the voltage divider.
-
@zboblamont Yes. 3V Mini Pro
@gohan Yes. 0.1uF capacitor.
@rozpruwacz Internal reference 1.1V. Have a external divider exactly as the example schematics on the home page, to get maximal 1.1 V with two AA batteries.As a first step I am trying to understand how the batteryPcnt can ever be higher than 100. With my code that should be impossible. Even if i put 5V on A0.
vBat should never be able to be higher than v_MAX
and therefore batteryPcnt should never be able to be higher than 100. -
@zboblamont Yes. 3V Mini Pro
@gohan Yes. 0.1uF capacitor.
@rozpruwacz Internal reference 1.1V. Have a external divider exactly as the example schematics on the home page, to get maximal 1.1 V with two AA batteries.As a first step I am trying to understand how the batteryPcnt can ever be higher than 100. With my code that should be impossible. Even if i put 5V on A0.
vBat should never be able to be higher than v_MAX
and therefore batteryPcnt should never be able to be higher than 100.@strixx What does your #ifdef MY_DEBUG sequence spit out?
-
@zboblamont Nothing strange. sensorValues between 800 and 1023, and correct corresponding vBat and batteryPcnt according to my formulas. But that's when I have the serial programmer connected.
I don't know how to get the serial output from debug without having it connected.
The strange values only appear when on battery. -
@zboblamont Nothing strange. sensorValues between 800 and 1023, and correct corresponding vBat and batteryPcnt according to my formulas. But that's when I have the serial programmer connected.
I don't know how to get the serial output from debug without having it connected.
The strange values only appear when on battery.@strixx I think you can disconnect power from the FTDI to the board and leave the battery connected, so long as gnd etc remain connected from FTDI...
Perhaps somebody can correct me if I'm wrong... -
I always think about this battery percentage. Where it gives its limits.
Then I see some project - "NodeManager"
GitHub
And there was some functions :// [11] the expected vcc when the batter is fully discharged, used to calculate the percentage (default: 2.7) void setBatteryMin(float value); // [12] the expected vcc when the batter is fully charged, used to calculate the percentage (default: 3.3)``` -
I always think about this battery percentage. Where it gives its limits.
Then I see some project - "NodeManager"
GitHub
And there was some functions :// [11] the expected vcc when the batter is fully discharged, used to calculate the percentage (default: 2.7) void setBatteryMin(float value); // [12] the expected vcc when the batter is fully charged, used to calculate the percentage (default: 3.3)```@kimot If there were a problem with the sketch it would equally apply when the ftdi is connected with the sensors connected.
I believe that is why @sundberg84 suggested measuring the voltage at A0... ;) -
@zboblamont
The voltage at A0 is at steady 0,8V with batteries.
Which should give sensor value 744.
The voltage of the two batteries is 2,88V.But as I wrote earlier it must be so that my multimeters internal resistance is not high enough. And is messing up the divider when measuring.
The calculated voltage at A0 should be 0,89V
Which should give sensorValue 828My sensors right now is reporting 100% then 253% and now 236%.
-
Ok. So connecting the node to serial interface, but without power from it. And power from same batteries.
The calculations is correct and multimeter is not measuring correct.This is debug out put:
First loop:Sensor value: 1023 Battery Voltage: 3.30 V Battery percent: 100 %Second and the following loops:
Sensor value: 877 Battery Voltage: 2.83 V Battery percent: 21 %So back to square one. When serial output is connected it works perfect.
When disconnected it starts reporting all messed up readings! -
Do you have an ldo voltage regulator? Maybe you could try 3 batteries for 4.5v output and use a linear regulator to have 3.3v or use 2 fully charged alkaline and power node without booster, as it could be the booster a bit too noisy.
My personal favorite solution is using a single LiFePo4 AA battery and vcc library, no buck/booster and voltage divider, everything much simpler -
I meant if you have one regulator to try, I think there may be something related to the booster. Try also a bigger capacitor on the booster output, and a big ceramic one if you have on the vcc of arduino