nRF5 SDK is not maintained anymore
More Info: Consider nRF Connect SDK for new designs

Automate nRF52840 Dongle running pc-nrfconnect-ble

Hello,

 I'm very unexperienced with low-level programming, so I apologize is some of my questions make little sense.

  We have this board that sends telemetry data using a nRF52840 to a Window 10 PC.  Looking for a quick and dirty way to scan for the board, connect to it, and record the RSSI value I found out the nRF52840 dongle.  Running Bluetooth Low Energy app that comes with nRF Connect for Desktop works like a charm, but now I'm looking for a way to replicate this thru LabView. I took a gander at the serial port communications between the app and the dongle and it's mostly HEX commands, so I tried looking around github for a piece of code or example that I could use to duplicate these commands, but I can't figure out where or what to look for..

 I'm hoping someone can point me to a piece of code/example or document that explains how to send and read the commands to a nRF52840 dongle programmed with pc-nrfconnect-ble.

Thanks.

  • Hello,

    Attached below is a python script for the pc-ble-driver-py I quickly put together which will connect to any BLE device named 'TARGET_DEV_NAME' and start logging the RSSI. You can use it with the same dongle and FW you use with the Bluetooth low energy app.

    Steps for testing the script:

    1. Install pc-ble-driver-py through PyPi: $ pip install --user pc-ble-driver-py

    2. Change TARGET_DEV_NAME in the script to match your device.

    3. Run script with python: $ python3 rssi_logger.py NRF52 <COM port for nrf52840 dongle>

    After the connection has been established you should start seeing the measured RSSIs from the connection:

    $ python3 rssi_logger.py NRF52 /dev/ttyACM0
    Serial port used: /dev/ttyACM0
    2022-04-11 15:54:27,049 [139762313049856/LogThread] Successfully opened /dev/ttyACM0. Baud rate: 1000000. Flow control: none. Parity: none.
    Received advertisment report, address: 0xC4A1E304973B, device_name: Nordic_UART
    New connection: 0
    Client requesting to update ATT MTU to 247 bytes
    Max rx octets: 251
    Max tx octets: 251
    Max rx time: 2120
    Max tx time: 2120
    RSSI: -39
    RSSI: -37
    RSSI: -37
    RSSI: -37
    RSSI: -40
    RSSI: -42
    RSSI: -38
    RSSI: -39
    RSSI: -39
    RSSI: -39
    

    I do not have much experience with LabView, but I hope you will be able to parse the log output from it.

    Best regards,

    Vidar

  • Thank you very much Vidar, unfortunately I wasn't able to take the time to learn Python (my programming experience is currently limited to Labview and VB 6.0 ;-). 

    At the end I took a different approach.  First I was able to open "pc-ble-driver" in VS2022 and build the "heart_rate_collector".  Then I modified the code to allow extended advertisements and to ouput the rssi.  Once I got the EXE where I wanted, I simply run it using System Exec.vi in Labview.

    Not the most elegant solution, but it's the quick and dirty way for someone looking for a very basic interface between the nRF52840 dongle and Labview.

    Quick side note, I also tried to write a .NET C# application using Windows UWP BluetoothLEAdvertisementWatcher and some cheapo USB Bluetooth adapters from Amazon, but even after enabling the AllowExtendedAdvertisements property, I wasn't able to scan extended advertisements, only the BLE legacy ones.

  • Good to hear that you found a solution, thanks for the update.

    Quick side note, I also tried to write a .NET C# application using Windows UWP BluetoothLEAdvertisementWatcher and some cheapo USB Bluetooth adapters from Amazon, but even after enabling the AllowExtendedAdvertisements property, I wasn't able to scan extended advertisements, only the BLE legacy ones.

    Extended advertisements must also be supported by the Bluetooth adapter. Maybe that is why it did not work.

Related