Measuring Battery life with BCM20732S

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Is there any documentation on trying to understand how battery monitoring works with the BCM20732S? I see that an input must be initialized as a GPIO_BAT setting and that it uses the UUID/profile set for the battery service/characteristic. However, my battery reads at 100 every time I can it, even though it isn't.


Futhermore, this is a snippet from our debug:

     lebat_bat_lvl_hdl:0063

     Battery level is critical, Shutting down

     Prepare Powersave!!!

     BLE_no_adv

     Start Powersave!!!

     Normal and Fine Timer killed

     Battery level: 0/100

     Fine Timer(1000 ms, 1/sec, 80 tick)

     Normal Timer(1 s, 80 tick)

     BLE_high_un_adv:timer(1)

     AppTimer(adv, conn) stopped: 1

     BLE_low_un_adv:timer(1)

Although it says shutdown, the app does keep running. Does anyone have any idea how I can get a correct relevant battery reading?

Thanks.

9 Replies
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog

Some background is needed.

The battery monitoring code in the bleapp\app directory is the ROM code (not patched in).  It's provided primarily as a reference and was not intended to be compiled directly.  What you can do is copy the necessry file to the RAM\<your app> directory, and then include those in the makefile.inc and rename the entry functions to something new. 

For example hello_sensor calls blebat_Init, you can change that to call _blebat_Init and then provide RAM code which will be doing something similar as what was done in the ROM version, but with your required modifications.

Would this sample be helpful?

Anonymous
Not applicable

Okay, I see. Thanks a lot. Sorry I didn't catch a similar discussion posted earlier.

0 Likes
Anonymous
Not applicable

Moving to the new SDK, my program seems to have stopped working.

Capture.PNG

Previously it would give me this message too (battery level is critical), but I could still proceed with the program.

Do you know what the cause of this error msg is and how to correct it?

thanks

0 Likes
Anonymous
Not applicable

Hello mochi,

I assume we can mark this older post as Correct since you have solved your issue here: Re: Getting blebat to work

Thanks

JT

0 Likes
Anonymous
Not applicable

Hello JT,

  Can I use the build-in ROM code of battery monitoring (blebat.c), when my VDD/VDDIO is feed from DC/DC converter which is outputting 1.8v?

  My design is use have VDD/VDDIO at 1.8v but leave P15 as battery monitoring PIN connect to battery voltage (power).

0 Likes
Anonymous
Not applicable

By <WICED-Smart-SDK>/Wiced-Smart/bleapp/app/blebat.c, fullVoltage used in blebat_calculateCurrentReportValue() is defined as 3200.

So you need to add your own battery monitoring for 1.8V I think.

Anonymous
Not applicable

Hi dmiya,

  Thanks for your comment.

  My case is:

  Battery -> DC/DC to v1.8 -> VDD/VDDIO/VBAT of 20732.

  Battery -> P15 of 20732.

  So, it's also the measurement between 0 ~ 3.6v.

0 Likes

I think you will find this discussion helpful: Getting blebat to work

mochi

0 Likes
Anonymous
Not applicable

With regards to the software for calculating the battery Level.

Is it possible to change the pin of which the battery level is been read? VBAT to P8.

From my understanding VBAT is been read as an ADC, the value is returned in mv.

If it is not possible to change it, is it possible to sample the voltage on my desired battery level pin (P8) and pass the reading to the variable in which VBAT is been recorded.

Also my maxlevel and emeptylevel is different, is it possible to change these variables?

Also if I desired to change the formula around a bit, is this also possible?

Regards,

Luke.

0 Likes