Bluz_DK On Board Battery Status/Voltage


#1

@eric, I would like to read on 2320 battery voltage and publish to the gateway. Please let me know how I can read Vin.

Thanks


#2

The simple way for now is to hook the battery to an ADC pin and read the voltage. There is a way to do this internally inside the nrf51, it is on our list: https://github.com/bluzDK/bluzDK-firmware/issues/36


#3

For the case with Bluz Battery Shield, is it possible to read the coin cell soc level and voltage just like Particle Power Shield?

https://github.com/spark/powershield

There is no pin out for coin cell (+/-) on Battery Shield. :cry:


#4

The 3V3 pin on the battery shield is the reference voltage to measure, so you can jumper that to an analog pin to read it.


#5

I am getting the analog value such as 763.
It represents the value of voltage, right?
I have read that the voltage value of coin cell will be relatively the same throughout the time unless it is completely discharged.
Does this mean that I cannot measure the SOC accurately?

int pinto3pt3 = 3;
int val = 0;
void setup()
{
}

void loop()

{
    System.sleep(SLEEP_MODE_CPU);

    val = analogRead(pinto3pt3);
  
    Particle.publish("3pt3 value is",String(val));

    delay(1000);

}

#6

It looks like you are calling analogRead on pin 3, is that right? Pin 3 is D3 which is not an analog pin.

Try measuring the voltage from pins A0-A5, it should give you correct results


#7

Modified the code slightly by changing the pin to A3. Results seem to be the same. :grin:
Hardware configuration : connected 3V3 pin with A3 pin through jumper wire.

int pinto3pt3 = A3;
int val = 0;
void setup()
{
  pinMode(pinto3pt3,INPUT);
}

void loop()

{
    System.sleep(SLEEP_MODE_CPU);

    val = analogRead(pinto3pt3);

    Particle.publish("3pt3 value is",String(val));

    delay(1000);

}


#8

Do you have a meter so you can independently measure the battery?

EDIT: I realized there is an error in the documentation. The ADC measures 0V - 3.6V, not 0V - 3.3V as it states in the doc. I will fix this.

So the measurement you are seeing is (751 / 1023) * 3.6 = 2.64V. That seems low, but I have seen coin cell batteries operate down to about 2.5V, so it could be possible. The best way to verify is to measure the battery with a separate meter.


#9

This is value published to console.

I would say the value is fairly accurate.
Thanks!

Next step is I have no clue how to convert voltage value to battery soc (showing like 90% , 75% as how battery level is presented in smart phone and laptop).

Any idea? :sweat_smile:


#10

That’s a little trickier. You can look at some datasheets of the batteries and try to gauge it, something like this may help you: http://data.energizer.com/PDFs/cr2032.pdf

Of course, that is one battery, others may have different characteristics. I would say pure percentage will be hard, but maybe something like 25%, 50%, 75% and 100% would be do-able with trial and error.


#11

FYI - Newest beta version allows you to read battery voltage without external connection: http://staging-docs.bluz.io/reference/system/#readsupplyvoltage


#12

I can confirm that reading the battery voltage is working in the latest Beta!