Send Battery Level notifications to nRF Connect app when battery level reaches certain level

Hello,
I am new to BLE and I need help with Battery Service notifications. I am using nrf52840dk, nrf sdk 17.1.0 and I am using ble_app_proximity example which already uses Battery Service.
I need to send a pop up notification from device to nRF Connect mobile app when battery level reaches 40%. Whenever battery level reaches 40%, a notification should pop up telling us that battery level has reached 40% please charge.

Can anyone please help me with this?

Thanks,
Kanthi Deep.

  • Hello Kanthi Deep,

    Can anyone please help me with this?

    Absolutely, you've come to the right place! :) 

    I am new to BLE and I need help with Battery Service notifications. I am using nrf52840dk, nrf sdk 17.1.0 and I am using ble_app_proximity example which already uses Battery Service.
    I need to send a pop up notification from device to nRF Connect mobile app when battery level reaches 40%. Whenever battery level reaches 40%, a notification should pop up telling us that battery level has reached 40% please charge.

    In the default ble_app_proximity application the battery notification will be sent as part of the handling for the NRF_DRV_SAADC_EVT_DONE event, through the call to ble_bas_battery_level_update. If you would only like it to update when it is 40% or lower you will need to implement a check or conditional here that verifies that the condition is met before the notification is sent.
    You could probably also reduce the sampling rate to be much more seldom before you are at < 40% for the first time, to conserve power, for instance.

    Best regards,
    Karl

  • Hello Karl,
    Thank you for replying so fast.
    I have a doubt about the function that you mentioned ble_bas_battery_level_update I thought it will just update the battery level in the app, but I need a pop up notification on the screen when the battery level is 40% like the one you receive on your phone when it is 20%.

    Thanks,
    Kanthi Deep.

  • Kanthi Deep said:
    Thank you for replying so fast.

    No problem at all, I am happy to help!

    Kanthi Deep said:
    I have a doubt about the function that you mentioned ble_bas_battery_level_update I thought it will just update the battery level in the app, but I need a pop up notification on the screen when the battery level is 40% like the one you receive on your phone when it is 20%.

    Oh, would you like to change the behavior of the smartphone application, not the peripheral device?
    There is unfortunately no way to add a popup notification / main screen notification for a specific characteristic value in the nRF Connect for smartphone application, to my knowledge.

    Best regards,
    Karl

  • Oh okay, but what about a pop up notification in the nRF Connect app itself. Is it possible? Like a small pop up box telling Battery is at 40%, please charge.
    The documentation on the nRF Connect app said that notifications are possible. Is there no way to add in code so that a notification will be displayed?
    Thanks,
    Kanthi Deep.

  • I do not think so, unfortunately.
    However, if you were to create your own smartphone application you could easily add this as a feature based on the received BAS notification.

    Best regards,
    Karl

Related