Battery reading?


#1

I noticed that there are 2 pins declared for battery readings. On my fully charged Pokitto, pin 2 seems to be around 80% the value of pin 1.
Does anyone have any info or experience with what these values are or mean?
I think they’re named batterypin1 and batterypin2 (not sure though, I’m not at my computer).


#2

Oh man, I really need to get to work on publishing the schematics

One is a reference value, generated by a chip that we put on the board exactly for this purpose.

You see, the way the charge % is measured in things like Gamebuino classic is actually not reliable at all because you need a real voltage reference. Otherwise your Vmax drops at the same pace as your Vrel and you really co’t know how much charge you have left.

I’ll get back on this soon.


#3

Yessss. (10 char…)


#4

Using the following, I get results, not sure how accurate…

AnalogIn battPin1(POK_BATTERY_PIN1);
AnalogIn battPin2(POK_BATTERY_PIN2);

    // battery pins 1 and 2, no idea what they represent
    int b1 = (int)(battPin1*330); // assume regulated power is 3.3v
    int b2 = (int)(battPin2*37000); // assume battery is 3.7v
    int battPercent = b2/b1;

Assuming that pin 1 is regulated 3.3v and pin 2 is direct from the 3.7v battery…
Does this seem correct to anyone, or is there more complex math to do?
According to my above calculation, I’m at ~95% on a full charge.


#5

You couldn’t have a pin directly on the battery. The processor runs at 3.3V, so the 3.7V (which could be as high as 4.2V) would exceed the value that could be read.

In any case, there really should be library functions for handling battery state monitoring.


#6

So really we need to know what the max values represent and not just guess…


#7

Yeeeeesss. I will get to this soon


#8

ANSWER

P0_23 is Vbat divided by 2

P0_22 is Vref, a 2.5V reference from a LM4040 http://www.ti.com/product/LM4040#

LM4040 is a Precision micropower shunt voltage reference

It means P0_22 is always 2.5V and P0_23 is current Vbat / 2

by comparing the analog input of the two pins, you get actual Vbat level

This is because devices like Gamebuino classic used a simple voltage divider to “detect” voltage level

but as Vbat drops, so does the 3v3

so only by using a LM4040 type voltage reference, you get an absolute voltage value