PSoC6 RSSI value measurement issue

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

cross mob
lock attach
Attachments are accessible only for community members.
SuRa_2245351
Level 4
Level 4
First like received First like given

Want to measure distance between android cell phone and PSoC6 device (CY8CKIT-062-BLE) using RSSI value and display it on UART. In this case I will be reading RSSI value of cell phone and determine its distance from my PSoC6 device and send it over UART. Please help me if anyone had done same on PSoC6 BLE or PSoC4 BLE.

Also I had attached project to measure RSSI value of connected device but it is not working , I know there is something wrong with code but unable to find. Please rectify if possible.

0 Likes
1 Solution
MeenakshiR_71
Employee
Employee
100 likes received 50 likes received 25 likes received

Hello rautinst_2245351​,

I see a mistake in your CY_BLE_EVT_GET_RSSI_COMPLETE event handling. The eventParam for this event is of type "cy_stc_ble_events_param_generic_t*" and the cy_stc_ble_events_param_generic_t structure has another element called "eventParams" and this is the element that contains the "cy_stc_ble_rssi_info_t*". So modifying the rssi_param line to below fixed the issue.

rssi_param = (cy_stc_ble_rssi_info_t*)(((cy_stc_ble_events_param_generic_t*) eventParam)->eventParams);

Some other notes -

1. In the CY_BLE_EVT_GAP_DEVICE_CONNECTED event, you don't have to get the address and then use GetPeerBdHandle to retrieve the bdHandle. The bdHandle member/element of "conn_param" already contains the bdHandle of the peer. So you can directly use it (conn_param->bdHandle).

2. Even though in theory RSSI gives approx. estimate of the distance from the peer. It should be noted that the environment loss can vary a lot and the distance estimated from RSSI might not give the actual distance (because of varying and lossy nature of environment). You will have to model your environment, find out the loss (again this can change) and the use it in RSSI equation to arrive at the distance. I hope you already understand this

Let me know if this helps.

Regards,

Meenakshi Sundaram R

View solution in original post

1 Reply
MeenakshiR_71
Employee
Employee
100 likes received 50 likes received 25 likes received

Hello rautinst_2245351​,

I see a mistake in your CY_BLE_EVT_GET_RSSI_COMPLETE event handling. The eventParam for this event is of type "cy_stc_ble_events_param_generic_t*" and the cy_stc_ble_events_param_generic_t structure has another element called "eventParams" and this is the element that contains the "cy_stc_ble_rssi_info_t*". So modifying the rssi_param line to below fixed the issue.

rssi_param = (cy_stc_ble_rssi_info_t*)(((cy_stc_ble_events_param_generic_t*) eventParam)->eventParams);

Some other notes -

1. In the CY_BLE_EVT_GAP_DEVICE_CONNECTED event, you don't have to get the address and then use GetPeerBdHandle to retrieve the bdHandle. The bdHandle member/element of "conn_param" already contains the bdHandle of the peer. So you can directly use it (conn_param->bdHandle).

2. Even though in theory RSSI gives approx. estimate of the distance from the peer. It should be noted that the environment loss can vary a lot and the distance estimated from RSSI might not give the actual distance (because of varying and lossy nature of environment). You will have to model your environment, find out the loss (again this can change) and the use it in RSSI equation to arrive at the distance. I hope you already understand this

Let me know if this helps.

Regards,

Meenakshi Sundaram R