Developer Portal Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Reporting Battery Level and Voltage

    Nicolas
    Established Member

    Reporting Battery Level and Voltage

    Hello,

    To report the battery status and Voltage, Im using the below code, but i'm getting in return 165 and 0.000

    1) does this make sense? how can i interpret this?

    2) To report the batery status and voltage with the sensing readings, I should  add them to publishDataFormat  right?

    Thanks

    ----------------------------------------------------------------------------------------------

    BSP_Charger_BQ2407X_Connect();
    BSP_Charger_BQ2407X_Enable(BSP_XDK_CHARGING_SPEED_1);

    BSP_ChargeState_T BatteryStatus;
    uint32_t Batoutput = 0;

    BSP_Charger_BQ2407X_GetStatus(&BatteryStatus);
    BSP_Charger_BQ2407X_MeasureSignal(0, &Batoutput);
    printf("%d \n\r", BatteryStatus);
    printf("%f \n\r",((float)Batoutput / 4300)*100);
    Batoutput = 0;

    3 REPLIES 3
    Shanmathi
    Established Member

    Re: Reporting Battery Level and Voltage

    HI Nicolas,

    The BSP GetStatus and MeasureSignal API's are not implemented currently for BQ2407X revision.

    You could use the BatteryMonitor module in common to get the measured battery voltage in millivolts.

    Retcode_T retcode = RETCODE_OK;
    uint32_t readBatteryValue = 0;
    float xdkBatteryInVolts = 0.0f;
    
    retcode = BatteryMonitor_Init();
    
    if (RETCODE_OK == retcode)
    {
    retcode = BatteryMonitor_MeasureSignal(&readBatteryValue);
    xdkBatteryInVolts = (float)readBatteryValue / 1000; 
    }
    

    For your second question, yes, you have to add in the  publishDataFormat .

    Nicolas
    Established Member

    Re: Reporting Battery Level and Voltage

    Thanks Shanmathi, let me ask you what is the xdkBatteryInVolts value range should be?  I'm getting a value of 4.36? Does it make sense?  should it be represented in percentage instead? like  65% full?

    Regards,

    Nick

    Shanmathi
    Established Member

    Re: Reporting Battery Level and Voltage

    Hi Nicolas,

    The BatteryMonitor_MeasureSignal API will retun the measured battery voltage in millivolts, which can be converted in the application to get in Volts.

    If you need a percentage represenstation, the logic could be done in the application.

    The range would be 0 - 4.65 Volts.

    Fore more explanation related to the electricaa charactersitics of Charger BQ2407X, you can refer  BQ2407X Charger  datasheet.

     

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist