This tutorial has been updated, go here for the latest version.
This tutorial will show you how you can test and debug your BLE application in a few different ways. It is meant as an introduction for beginners, and will only provide some basic insight. The tutorial will serve as a continuation of this previous tutorial, and will therefore use the ble_app_uart as an example.
The ble_app_uart project does two things that we can easily test. First, it sets up a wired UART connection between the kit and the computer, via the USB cable. Then it sets up an UART BLE service that we can connect to. Whatever is sent from the computer to the kit is relayed to the connected device, and vice versa. In other words, the kit works as a wireless bridge between the device and the computer.
In order to communicate with the nRF51 via UART, we will need to set up a terminal on our computer. The command prompt in Windows can be used, but is very troublesome to use. There are several different third-party programs that are suited, and this tutorial will be using Termite. Download and install the latest version, and you are ready.
In order to connect to the DK we have to select the correct COM-port in Termite. First of all, connect the nRF51 DK running the ble_app_uart project to your computer. Open up Termite and click settings. Depending on what devices you have on your computer, you might have several choices, as shown below.
To find the correct port, follow these steps:
Go to the start-menu in Windows, and type devmgmt.msc to open Device Manager.
Scroll down and expand Ports (COM & LPT)
Find the Port named JLink CDC UART Port, and note the number in the paranthesis.
If you have more than one Jlink UART Port, unplug the one you want to use, plug it back in, and observe which one that appeared last.
Go back to Termite and select the correct port. The default UART settings in the ble_app_uart project use a baud-rate of 38400 and RTS/CTS flow control. The rest of the settings are default (8 data bits, 1 stop bit, no parity). Because the project uses RTS/CTS hardware flow control, the terminal must send an RTS (Ready To Send) signal to the DK before they can start communication. There are two ways to handle this problem; turn off hardware flow control in the development kit, or configure the terminal to use hardware flow control. Both methods will be discussed here.
Make sure the DK is connected to the computer, and the ble_app_uart project is running. (LED 1 should be blinking if you followed the previous tutorial)
In Termite, connect to the correct COM port with the settings described above
In Termite, go to settings, and under Plug Ins, enable Status LEDs. Click OK
Click on the dark green rectangle above RTS to set this signal high.
The text Start... should now appear in the window below.
Open the ble_app_uart project
In the main file, find the uart_init function
In the comm_params struct, change the fifth variable from APP_UART_FLOW_CONTROL_ENABLED to APP_UART_FLOW_CONTROL_DISABLED
It should now look like this:
const app_uart_comm_params_t comm_params =
In Termite, go to settings and set flow control to none.
Rebuild the project and flash it to the DK
The text Start... should now immediately appear in Termite
You have now verified that the project is running and is successfully sending on UART!
Next, we can test the BLE capabilities and check if we can connect to the device and use it as intended.
There are several ways in which we can connect to the DK. Two of them will be discussed here, namely with either a mobile device, or the nRF51 Dongle.
If you have a device that supports BLE, you can download the nRF Toolbox from Google Play, or App Store if you are on iOS.
Download and install nRF Toolbox
Open nRF Toolbox, and click UART
Make sure the nRF51 DK is running the ble_app_uart project (LED1 should be blinking every 2 seconds, indicating that it is advertising)
If you didn't change the device name in the project, Nordic_UART should appear on the list of available devices
Click on Nordic_UART
If everything went well, swipe right inside the app, and you will see something like below:
In Termite, you can now type anything in the bottom textbox, and send it to the DK
The text will then be sent by the DK, to your device, and display the text in the nRF Toolbox UART app
Congratulations! You have now tested the ble_app_uart project and verified that it works!
If you have the nRF51 Dongle, you can use it to connect to the nRF51 DK.
Plug in the dongle in a USB port in your computer
Open the Master Control Panel, and select the COM-port for the Dongle.
If the Log says No response from master emulator you will need to flash the dongle with the latest Master Emulator Firmware:
Go to File -> Flash programming and click Program
It should now look like below
Click Start Discovery
If the ble_app_uart project is running on the DK, you should see Nordic_UART under discovered devices in the master control panel
Click on Nordic_UART, and then click Select Device
Click Connect, and if it was successful, click Discover Services
Click Enable Services so the DK is allowed to send notifications to the Master Control Panel
The Service Discovery panel in the Master Control Panel should now look like this:
The two devices are now connected and ready to communicate. The two interesting characteristics are UART TX and UART RX in the "UART over BLE" service. These are seen from the DK's perspective, so the TX line is what is being transmitted from the DK, to the dongle, and the RX line is the other way around. You can now try the following:
In Termite, send some text to the DK by entering it in the bottom text-field, and press enter (make sure Append LF is checked in Termite settings)
In the Master Control Panel, observe that the TX Characteristic has changed to the text you just sent. (note: if you send more than 20 bytes, only the last 20 bytes will be seen in the characteristic)
For example, if you enter the text "Hello" in termite, you will see the following in Master Control Panel:
The values are hexadecimal, and a quick lookup in the ASCII table reveals the letters H (0x48) e (0x65) l (0x6C) l (0x6C) o (0x6F). 0x0A is the new-line character that was appended at the end of the text by Termite. To see why this character is required, you can inspect the UART0_IRQHandler function in the main file in the ble_app_uart project.
Now we can try sending some text the other way, by writing to the RX characteristic.
In Master Control Panel, click on the UART RX characteristic.
In the Value field below, select text, enter some text, and click Write
The same text should now appear in you Termite window
I had a similar issue with termite. You'll have to reset the board, press and again reset the board. For crippling the stream control, I utilized Method two - debilitating in the task Do my Assignment Australia. Functioned admirably! Much appreciated.
I found that in above discussed example (ble_peripheral\ble_app_uart), the maximum number of data bytes that can be transferred are 60. How to increase the number of bytes (length of data) to be transferred? Which buffer I need to change?
What can be done/ which approach should I take if I want to transfer a large data, say 2 Mega bytes over a BLE?Thanks! Sanket
Even I programmed the Dongle with the latest Master Emulator firmware, the log still show: "No response from master emulator". And I can not correctly use the dongle correctly as a peer device.
I am new to BLE communication. What should I do to make it work?
Hi I am new to nrf51 Dk, so it might be a stupid question. For this tutorial, can I replace the nrf51 Dongle with another nrf51 Dk board? Because I do not have nrf51 Dongle. Please help thanks!
@Sri_guy In the code that comes in SDK11 for nordic NRF52, the defined baudrate is: UART_BAUDRATE_BAUDRATE_Baud115200. To connect with 38400 you have to change this constant.