BLE UART

We have an NRF52833 connected to the host board(runs LINUX) through UART can anyone help us with the code that goes in the NRF module that can make it work as a transceiver module(just like BLE adaptor) like sending data received from BLE to UART and data received from the host board to BLE

The final solution we are looking for is as follows: Using python on the host board we should be able to use NRF as a BLE adaptor and connect to BLE devices like sensors and receive data from them. All the connection and scanning and reading data code should be controlled or written in python and NRF should act like a transceiver module 

Can it be done? or are we looking in the wrong direction? 

  • Hi,

    There are several possible approaches here, which is best depends on your use case.

    1. You can use Bluetooth: HCI UART on the nRF device to run the Bluetooth controller there, and use HCI over UART. On the LInux side, use BlueZ as the Bluetooth host layer. This way the nRF will seem like a generic Bluetooth dongle from Linux and you can use it with standard Bluetooth APIs. This will only work with hosts that support HCI, so Linux, but not Windows or Mac, for instance.

    2. You can also use the Bluetooth shell form zephyr/tests/bluetooth/shell/ on the nRF, and interact with it from a script that sends shell commands and parse the output.

  • Option 1 looks fine as we are using Linux. 

    To implement it: 

    1) for Bluez we can use pybluez - https://github.com/pybluez/pybluez

    2) " HCI UART on the nRF device to run the Bluetooth controller "- Can you suggest an example code to start with? 

  • Hi,

    I forgot to add the link, but HCI UART is an example that works out of the box (there are also other variants for other transports like USB). The example documentation also covers how to interface with this from Linux.

  • 1) Flashed HCI_UART sample using below steps 
    -west build -p auto -b nrf52833dk_nrf52833 samples\bluetooth\hci_uart
    -west flash
    2)Connected the board to linux machine and ran the below command 
    -sudo btattach -B /dev/ttyACM0 -S 1000000 -R
    btattach
    3) ran hciconfig 
    output 
    hciconfig
    can see two Bluetooth devices one is of laptop and one is the NRF connected 
    4) ran btmon
    output 
    btmon
    5) After that tried to run hciconfig scan , bluetoothctl scan , hci1 find -l but none of this was able to scan for ble using nrf as dongle 

    why is the device BD address 00:00:00:00 is it a valid address? 

  • Everything is working. thank you so much 
    the error was in my Linux board the UART device is /dev/THS1, not ACM0 replaced it in btattach command and everything is working. I also tested the HCI_USB example which also works.

1 2 3 4