This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How i use battery service level measurement?

Hello,

I am using NRF52832 boars s132 and sdk is 13.1. I have developed my application is read analog accelerometer valie and send to mobile apps. Now i want to also battery indicator in my android apps. So how i can use battery service with my existing BLE UART code. Noe i use sdk proximity example but it hows battery update level within 120sec. But due this adc my accelerometer channel adc is not work. So sir please tell me how i can merge battery service example with my code. Is it possible to check battery and update also without using ADC. Please tell me or give some references example code. Now on my current application i use 12 bit ADC with 3 channels and 2.4 Adc reference. With high sampling rate. Please let me know how i check my device battery in Android apps.

Thanks in Advanced.....

  • Hi Vishb! So you are developing an Android application that reads analogue accelerometer data from the nrf52832 development kit and shows these values on your phone, right? Check out this case. Might be helpful. But first off, I would like to ask what you mean by battery indicator? Are you referring to battery voltage or state of charge (%)? If you mean state of charge, you can download the Nordic Thingy Android app from Github. The newest version of the Thingy app shows the state of charge of the Thingy. I don't expect that you have a Nordic Thingy, but this could be a very good starting point, as the Android Thingy app is written in Java and not in C.

  • Have a look at the MainActivity.java file. Look at the onBatteryLevelChanged() and updateBatteryLevel() functions, as well as the R.id.battery_level and battery_level_percent variables. In addition, I would download the nrf52 Thingy firmware from github. If you take a look at the m_batt_meas.c file, you can find all of the functions required to calculate the State of Charge from the battery voltage. Hope that helps!

  • Hi Bjorn,

    We have one issue for updating battery measurement interval every 1 minute

    I have update battery services in ble_app_blinky example and changed this:

    #define BATTERY_LEVEL_MEAS_INTERVAL     APP_TIMER_TICKS(60000) 

    But it not working every 1 minute it only get battery level at once and start this timer repeated and restart again.

    I have selected in timer init function this APP_TIMER_MODE_REPEATED mode.

    Will please help me why it so happen?

    And one another thing is we have 3 BLE slave which is running ble_app_bliny example and one master are using ble_app_multilink central.

    Our problem is when this three slave is connected to central how we identify which battery level of which connected slave

    I know this can be identify with the help of connection handle but this connection handle is not fixed it dynamic as per connected which one first. Our 3 BLE slave is fixed first second and third and if second is connected to central at that time how we know in central this s second slave and this battery level of that slave.

    Is any configuration to fixed connection and identify battery level by this basis.

    Please let me we are more troubling on this...

    Looking forward your reply..

    Thanks..

  • Hi,

    This case might be helpful regarding the battery level interval. This case too. This one too.

    Are you connecting the slaves one after the other in the same way (e.g. by having a different device name for each & connecting to the first device first, then the second & finally the third)?

    Kind Regards,

    Bjørn

  • Thanks Bjorn for your reply,

    Now when i enabled RTC1 in sdk_config.h so battery app timer is trigger repeated

    static void battery_level_meas_timeout_handler(void * p_context)
    {
    UNUSED_PARAMETER(p_context);
    NRF_LOG_INFO("battery_level_meas_timeout_handler");
    ret_code_t err_code;
    err_code = nrf_drv_saadc_sample();
    APP_ERROR_CHECK(err_code);
    }

    but at central side battery level is receive only once. So when i debug in ble_app_blinky the saadc_event_handler() is not all back as per battery time out handler. Will you please help me whats going wrong.. Why this saadc event is not call and not update battery level.

    Thanks......

Related