In order to follow this guide, it is necessary to have read and followed the nRF5 DK user guide. The user guide explains the required tools and software, and how to set them up. It also gives a brief explanation of the layout and hardware of the Development Kit, making it easier to follow this tutorial.
Download and extract nRF5 SDK 12.2
Connect the nRF5 DK to the computer with a USB cable
Flip the power switch in the bottom left corner to "ON"
Before the DK can be programmed with a user application, it must be flashed with the correct SoftDevice. The SoftDevice is a preprogrammed hex file that contains all the necessary functions to control the radio in BLE mode. These functions are hidden from the user so that all one has to think about is creating the application. Depending on which chip and SDK is being used, the correct Softdevice must be chosen. To determine which Softdevice you need, the following compatibility matrix(nRF51/nRF52) can be used. The differences between the softdevices are listed in the SDK documentation.
For this tutorial we will use SoftDevice s13x, s13x can act in both peripheral and central roles. In order to figure out which SoftDevice is compatible with which SDK version we can consult the compatibility matrix. For nRF51 we will use s130 version 2.0.1 and for nRF52 we will use s132 version 3.0.0 Both are compatible with nRF5 SDK 12.2
Next we need to flash the SoftDevice onto the development kit.
Download and install the command line tools executable.
Open the command line and type:
This will list the different input parameters and other help documentation. If the command line reports that it cannot find the program follow the instructions below in Adding PATH Variables.
Sometimes nrfjprog.exe will not be added to PATH by default, this is how to do it manually. If you are looking for more information on what the PATH variable is, please consult this answer at Superuser.
In windows 7 (for other systems consult the link above) navigate to environment variables by:
Then click on Advanced system settings
Click on Environment Variables...
Add the variable to path by clicking the Edit... button
Then add nrfjprog by adding ´;C:\Program Files (x86)\Nordic Semiconductor\nrf5x\bin´ to the end of the variable value for PATH. Make sure that you add a ; between entries in PATH values, i.e. path1;path2.
Then press OK. Now you will be able to see the help dialog when you type nrfjprog --help in a new command line.
The SoftDevice hex file can be found in
Program the hex file by first erasing and then programming the chip with:
nrfjprog --family nRF51 --eraseall
nrfjprog --family nRF51 --program [SOFTDEVICE_LOCATION]\s130_nrf51_2.0.1_softdevice.hex
nrfjprog --family nRF52 --eraseall
nrfjprog --family nRF52 --program [SOFTDEVICE_LOCATION]\s132_nrf52_3.0.0_softdevice.hex
If you want to expand on this you can even run these commands directly from Keil, see this blogpost.
In your SDK folder the project can be found in:
If you see the following message, click “yes”.
If you are using the PCA10028 (nRF51 DK) or PCA10040 (nRF52 DK) board you can now compile the code and load the program onto the board. If you are using a different board, however, you must change a definition in the project to make it work as expected.
In order to make it easy to port projects between different boards, all projects come with a board support package. In the main.c file, it can be seen that bsp.h is included, which in turn includes boards.h. In the latter file we see some preprocessor directives that check if a certain symbol is defined, and if it is a corresponding header file will be included. These header files are the board-specific files that map the correct pins to the correct external components. For example, on the nRF52 development kit, LED_1 is connected to pin 17, while on the nRF51 development kit, LED_1 is connected to pin 21. Porting a project to a different board is then a matter of simply defining the correct board in the project. In Keil, project defines can be entered in the target options.
In the C/C++ tab, change the BOARD_PCA10028 symbol in the list of Preprocessor Symbols to the board you wish.
The project can now be compiled and flashed onto the development kit.
If everything is working as expected, you can move on to the next step, which will show how to test and debug the ble_app_uart application you have built and flashed.
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 nRF5 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 nRF5 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 115200 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 (HWFC), 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 app 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 nRF5 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 nRF5 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 your Termite window
Now that you have set up and run your first example your are ready to continue development. Check out the tutorial section here on DevZone for specific examples. If you encounter troubles try searching DevZone and see if someone has had and/or fixed the problem before, create a question if you can't find anything.
Hello,i use the ses run the ble_uart program ,it show download succussful. However, the LED1 doesn't turn on. The pca10059. I want to know what the question here,how can i solve the question?Thank you.
First of all, thanks for great tutorial. I am experiencing a rather unusual problem. Two weeks ago, I got a new phone and I tried to connect following this tutorial, and I succeeded with no problem. However, two days ago, I did the same thing, and now I have a problem connecting. Whenever I try to connect, I get the message that the device doesn't have the right services (notification on my phone). I am using Android smartphone. I have tried programming softdevice with both cmd tools and nrf Studio, and each time I successfully download the code. Communication with PC (in termite) works well too. I will post a screenshot with log messages. I hope anyone can help with this. Thank You in advance!
I'm attempting to reproduce this instructional exercise and I get the association between my iOS application and termite and I can send information however it just shows up as just bytes like this (0x00000001706424b0) and not ASCII characters. I am utilizing the SDK 12.1 on the NRF52DK and not by essay writing help service any means beyond any doubt what to give that will tackle this issue, fresh out of the box new to microcontrollers and the NRF52DK framework by and large.
Hi, thanks for the detailed tutorial, but when I was compiling the project (I am using PCA10028), it was not successful and KEIL5 display this:
it looks like I didn't install NordicSemiconductor.nRF_DeviceFamilyPack.8.11.1.pack according to the message (in fact, I already installed NordicSemiconductor.nRF_DeviceFamilyPack.8.15.0.pack). Then I downloaded NordicSemiconductor.nRF_DeviceFamilyPack.8.11.1.pack from KEIL and complied it again, it was still not successful, and KEIL5 display this:
it looks like 8.11.1 pack is not suitable for my board? how can I fix this problem? Thanks a lot!
I am working on the nRF52840 and IOS 'nRF Toolbox'. I can see the LED1 blinky and then when I open the 'nRF Toolbox', click 'UART', I could only find a device named 'Nordic_Prox', connect it the LED1 keeps lighting. But through log from my handphone, it says 'connecting to : Nordic_Prox' and 'No UART connected'.
I don't know how to deal with this, could any friends give me some guidance?
Thank you very much!