- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm trying to detect the battery level of my device in order to allow or not the connection of the BLE, I've seen the BLE battery level example but I didn't understand how does it works. I have seen this:
Cy_BLE_GetBatteryLevel, Cy_BLE_GetTemperature...etc. API Ambiguity
ad I have used it in my code using the part of the example code that there is into the discussion, but it doesn't work.
Can anyone explain me how to get the battery level in a simplest way without using external resources?
thanks!
Solved! Go to Solution.
- Labels:
-
ispn:40049:1:0
-
l1:314:1:0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please refer to below tips with use of Cy_BLE_GetBatteryLevel()
a. You can not pool Cy_BLE_GetBatteryLevel function in "while" loop.Those function is a non-blocking function and value is informed through 'CY_BLE_EVT_RADIO_VOLTAGE_LEVEL' event. Please add some logic to call next time only if previous completed (receive CY_BLE_EVT_RADIO_VOLTAGE_LEVEL) event.
b. the parameter comes with CY_BLE_EVT_RADIO_VOLTAGE_LEVEL event should be generic event.
case CY_BLE_EVT_RADIO_VOLTAGE_LEVEL:
{
cy_stc_ble_events_param_generic_t *param = (cy_stc_ble_events_param_generic_t *)eventParam;
if(param->status == 0u)
{
DBG_PRINTF("CY_BLE_EVT_RADIO_VOLTAGE_LEVEL: %u \r\n", *(uint16 *)param->eventParams);
}
break;
}
c. The voltage measured through Cy_BLE_GetBatteryLevel() is VDDR_HVL, not VDDR.
Let me know if the above helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
API Cy_BLE_GetBatteryLevel() occupies no any external resources, and it's work flow is pretty simple.
Could you tell how your code is going with calling the API Cy_BLE_GetBatteryLevel()? Have you ever tried the project attached in thread -
Cy_BLE_GetBatteryLevel, Cy_BLE_GetTemperature...etc. API Ambiguity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes I've tried the project but it didn't work, when I call Cy_BLE_GetBatteryLevel () I cannot connect the ble and he gives me an error
Cy_BLE_GetBatteryLevel API Error: 160004
I've found also this other thread How to get Voltage of PSOC 6 without ADC but I don't know how the LVD works and in which way I can recall it..
Have you any suggestions or part of code which I can refer to?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please refer to below tips with use of Cy_BLE_GetBatteryLevel()
a. You can not pool Cy_BLE_GetBatteryLevel function in "while" loop.Those function is a non-blocking function and value is informed through 'CY_BLE_EVT_RADIO_VOLTAGE_LEVEL' event. Please add some logic to call next time only if previous completed (receive CY_BLE_EVT_RADIO_VOLTAGE_LEVEL) event.
b. the parameter comes with CY_BLE_EVT_RADIO_VOLTAGE_LEVEL event should be generic event.
case CY_BLE_EVT_RADIO_VOLTAGE_LEVEL:
{
cy_stc_ble_events_param_generic_t *param = (cy_stc_ble_events_param_generic_t *)eventParam;
if(param->status == 0u)
{
DBG_PRINTF("CY_BLE_EVT_RADIO_VOLTAGE_LEVEL: %u \r\n", *(uint16 *)param->eventParams);
}
break;
}
c. The voltage measured through Cy_BLE_GetBatteryLevel() is VDDR_HVL, not VDDR.
Let me know if the above helps.