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

Proximity testing nRF51422

hi, 

I’m new to nRF5x BLE devices. 

I need to create a code for a project where i’m using a nRF51-DK device. So, I’m trying to demonstrate that the further the nRF51-DK is from the phone the less number of LEDs that light up, while closer the devices, the more LEDs light up. 

  • The "Received Signal Strength Indicator" (RSSI) level will give a rough estimate of the distance between the phone and the nRF51-DK. The further away the phone is, the lower the RSSI value will be.

    Initially you will need to call sd_ble_gap_rssi_start(..), which will start to report the signal strength to the application. Whenever the RSSI value changes, a new event is reported.

    In order to get the the RSSI value, the function sd_ble_gap_rssi_get(..) needs to be called, which will get the signal strength for the last connection event.

    The mentioned functions are part of the Generic Access Profile, and can be found here (for softdevice S130)

    Best Regards Simon Iversen

  • Thank you for you response Simon,

    Is this the same approach I would take if I wanted to get the RSSI before they are connected?

  • No, it is not. The approach I provided uses the current connection in order to get the RSSI value, it does that by using the connection handle. The connection handle will be received after the event BLE_GAP_EVT_CONNECTED occurs, thus after a connection between the microcontroller and the phone is formed.

    In order to get the RSSI value before establishing a connection, you will need  to use advertising. Advertising means that one device will advertise blindly and another device will listen and receive the advertisement packet. Then you can get the RSSI value from the advertising report event structure, ble_gap_evt_adv_report_t (https://devzone.nordicsemi.com/f/nordic-q-a/10668/rssi-without-connection).

    In this way only one device will get the RSSI value, and I guess you would want it to be the microcontroller (to turn on LEDs), then you would want to use the phone as advertiser and your nRF51-DK as a scanner. However, there are some disadvantages with a setup like this: https://devzone.nordicsemi.com/f/nordic-q-a/23605/smartphone-as-peripheral

    I hope this helps.

Related