[BLE] Examples related to peripheral_uart(BLE UART Service), central_uart(BLE Central UART)

Hello,

I am programming BLE with the nRF52840-DK.

  • Toolchain Manager: v1.3.0
  • IDE: Visual Studio Code (VSCode)
  • SDK: ncs v2.6.0

My implementation goals are as follows:

  • A(Central): Receive commands from a computer and transmit them to B via Bluetooth. Data received from B is then transmitted to the PC via UART communication.
  • B(Peripheral): Acquire data from an ADC and transmit it to A via Bluetooth.

To achieve this, I have been studying the peripheral_uart (BLE UART Service) and central_uart (BLE Central UART) examples. However, I have not been able to find a way to configure the bitrate (speed) for Bluetooth in these examples. Could you point out if I am missing something?

Thank you.

P.S. Have I appropriately assigned the roles of central and peripheral?

Parents
  • Hello,

    P.S. Have I appropriately assigned the roles of central and peripheral?

    Well, I can't tell without knowing exactly what you did, but if you programmed one board each with peripheral_uart and central_uart, then the roles are assigned by the samples. 

    The baudrate of the UART is by default 115200, so if you just want to test it, you can connect a terminal with this baud rate. If you are using the DKs, the UART will be routed through the debugger, so you can just select the COM port for the debugger, and it will figure things out. 

    If you want to change the baudrate, on the other hand. It is specified in the board files. It is not common to edit these board files, as they will apply to anyone using the SDK that you are using, in all samples. Instead, you can create a file called nrf52840dk_nrf52840.overlay, and place it in the same folder as your prj.conf file. Anything you write in this file will overwrite the default settings from the board files. You may need to delete your build folder, and create the build configuration once more, just to make sure that the debugger picks up the new overlay file.

    If you are using Visual Studio Code, and you have opened the sample, you can find the board file here:

    Somewhere in that file you will find something like.

    &uart0 {
    	compatible = "nordic,nrf-uarte";
    	status = "okay";
    	current-speed = <115200>;
    	pinctrl-0 = <&uart0_default>;
    	pinctrl-1 = <&uart0_sleep>;
    	pinctrl-names = "default", "sleep";
    };

    If you copy this entire chunk, and paste it into your overlay file, you can change the baudrate there. 

    As for the "bitrate for Bluetooth" that is a very complex question. It doesn't operate with a bitrate, but there are several connection parameters that affects the payload throughput, if that is what you mean.

    For some more information on this, I suggest you check out the Nordic Developer Academy, and the course about Bluetooth Low Energy Fundamentals. Particularly Lesson 3 talks about the connection parameters, and what they do.

    Best regards,

    Edvin

  • Thank you so much for the detailed response! I studied Bluetooth based on the sites you recommended.
    I have two additional questions:

    1. Increasing the data rate between PC and Dongle
      I used UART for communication between the PC and Dongle, but the maximum data rate is 1 Mbps, which seems too slow. I'm okay with using additional hardware if necessary. Is there a way to increase the data rate between the PC and Dongle to around 2 Mbps?

    2. Controlling the data rate in NUS
      It seems that NUS (Nordic UART Service) does not have a way to control the data rate(Bluetooth). I want to use a Bluetooth speed of 2 Mbps. Instead of using NUS, I think I need to program Bluetooth directly. Do you have any recommended examples for this?

  • seongmincho said:
    Increasing the data rate between PC and Dongle

    The PC doesn't have UART directly. It communicates via the onboard debugger that translates from UART to USB protocol if you are using the nRF52840 DK, and it uses USB directly if you are using the nRF52840 dongle (because it doesn't have a debugger).

    It is also possible to use the nRF's peripheral USB on the DK if you desire this. This way I believe you can increase the speed to more than 1MBPS. 

    seongmincho said:
    Controlling the data rate in NUS

    The NUS doesn't actually have anything to do with UART. That is just the name of the service. You can put whatever data you'd like into the buffers, and send it over BLE. The lessons that I pointed to in DevAcademy shows you how to increase the throughput, but 2MBPS is the physical baudrate on the radio. But you will not be able to acheive a 2MBPS throughput. The theoretical maximum of a BLE link today is about 1.3MBPS of actual payload. Is that sufficient for your usecase?

    Best regards,

    Edvin

  • 1. USBD(Universal serial bus device)

    oh i see. I will study the USBD. Could you recommend some examples for me?


    2. Blue tooth

    1.3Mbps seems sufficient, could you provide some examples?

    If a higher data rate is needed, should we use something other than Bluetooth?

  • Hello,

    For USBD, check out the usb cdc_acm sample found in ncs\zephyr\samples\subsys\usb\cdc_acm

    The Running description says you need to specify a baudrate, but this is not really used as long as it is used for USB all the way (and not USB to UART). 

    seongmincho said:
    1.3Mbps seems sufficient, could you provide some examples?

    You can check out the throughput sample. (ncs\nrf\samples\bluetooth\throughput), but you can also follow the instructions in the developer academy course. Increase the MTU and data length to a maximum, and send data using notifications. To test the speed, send dummy data and make sure to queue it up as much as you can. Long packets gives higher throughput than short packets. Also, a connection interval of something like 50 or 100ms gives a decent throughput. A very short connection interval is not ideal for a high throughput. 

    Best regards,

    Edvin

Reply
  • Hello,

    For USBD, check out the usb cdc_acm sample found in ncs\zephyr\samples\subsys\usb\cdc_acm

    The Running description says you need to specify a baudrate, but this is not really used as long as it is used for USB all the way (and not USB to UART). 

    seongmincho said:
    1.3Mbps seems sufficient, could you provide some examples?

    You can check out the throughput sample. (ncs\nrf\samples\bluetooth\throughput), but you can also follow the instructions in the developer academy course. Increase the MTU and data length to a maximum, and send data using notifications. To test the speed, send dummy data and make sure to queue it up as much as you can. Long packets gives higher throughput than short packets. Also, a connection interval of something like 50 or 100ms gives a decent throughput. A very short connection interval is not ideal for a high throughput. 

    Best regards,

    Edvin

Children
No Data
Related