Waveshare NRF52840 User manual

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 1/ 72
NRF52840 Eval Kit
User Manual

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 2/ 72
CONTENT
Chapter 1. Overview..................................................................................................................................5
what’s on Board ..............................................................................................................................5
Chapter 2. Setup Developing Environment ......................................................................................7
Install Keil and related Pack ...........................................................................................................7
Install SEGGER Embedded Studio for ARM 4.10a ..................................................................7
Serial driver install .............................................................................................................................7
Install Jlink driver ...............................................................................................................................8
Install nRFx-Command-Line-Tools..............................................................................................9
Install APP.............................................................................................................................................9
Peripherals demo............................................................................................................................10
Hardware connection............................................................................................................10
Download samples without Softdevice..........................................................................11
Download Samples with Softdevoce...............................................................................13
Chapter 3. Creating new project........................................................................................................15
Project template..............................................................................................................................15
Create a new project......................................................................................................................16
Chapter 4. Controling LED ...................................................................................................................20
Codes ..................................................................................................................................................20
Hardware Connection ...................................................................................................................21
Chapter 5. UART ......................................................................................................................................23
Codes ..................................................................................................................................................23

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 3/ 72
Hardware ...........................................................................................................................................27
Chapter 6. SPI ...........................................................................................................................................29
Loopback testing ............................................................................................................................29
Drive OLED ........................................................................................................................................30
Hardware ...........................................................................................................................................31
Chapter 7. I2C...........................................................................................................................................33
Scanning Slave devices.................................................................................................................33
Read data from BME280 ..............................................................................................................33
Read data from MPU6050 ...........................................................................................................37
Hardware ...........................................................................................................................................38
Chapter 8. NFC.........................................................................................................................................41
Codes ..................................................................................................................................................41
Hardware ...........................................................................................................................................43
Chapter 9. Bluetooth..............................................................................................................................44
Preparation........................................................................................................................................44
Install softdevice .............................................................................................................................44
Bluetooth serial transparent .......................................................................................................44
Bluetooth against losing ..............................................................................................................47
Bluetooth Beacon (Support WeChat Shake).........................................................................49
Wireless Mouse ...............................................................................................................................52
Wireless Keyboard..........................................................................................................................53
CSCS ....................................................................................................................................................55

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 4/ 72
Bluetooth Master- Cardiotachometer.....................................................................................56
Master-Slaver-BLE Relay ..............................................................................................................58
Chapter 10. MESH...................................................................................................................................62

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 5/ 72
CHAPTER 1. OVERVIEW
NRF52840 Eval Kit is a development/evaluation kit based on nRF52840, features
Arduino / Raspberry Pi connectivity, and several common peripherals.
It supports the new generation Bluetooth 5.0, compared to Bluetooth 4.0, the data
rate is twice, up to 2Mbps, the transfer distance is quadruple. Based on the ARM
Cortex-M4F architecture, the CPU frequency achieves up to 64MHz. Bluetooth MESH
1
and 2.4GHz radio are also available, that means higher performance, and more
suitable applications.
Thanks to the onboard Arduino / Raspberry Pi compatible headers, both Arduino
shields and Raspberry Pi HATs can be attached at the same time, make it easy to use
more expansion resources.
WHAT’S ON BOARD
1
At least three NRF52849 modules are required for Bluetooth MESH networking

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 6/ 72
1. Arduino headers: for connecting
Arduino shields
2. Raspberry Pi GPIO header: for
connecting Raspberry Pi HATs
3. USB TO UART interface
4. USB port: the USB port of nRF52840
5. 4PIN SWD debugging interface:
for connecting ARM Debugger to
program / debug
6. 3.3V/5V power input/output:
provides power output OR powered
from external power supply
7. Core52840: nRF52840 core module
8. CP2102: USB TO UART converter
9. Buzzer
10. RT9193-33: 3.3V voltage regulator
11. Optical sensor
12. Keys: RESET and USER KEY
13. LEDs
PWR: power indicator
RXD/TXD: nRF52840 UART RX/TX
indicator
LED1~LED4: USER LEDs
14. Power switch
USB: powered from USB connection
Battery: powered from CR2032
battery
15. NFC antenna connector
16. TF card slot
17. CR2032 battery holder
18. Jumpers
Short the jumpers: connect the
onboard peripherals to I/Os in
example code
Open the jumpers: connect to
custom I/Os via jumper wires
19. Current testing pads: 0Ω resistor is
soldered by default, remove the
resistor to test current of the board

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 7/ 72
CHAPTER 2. SETUP DEVELOPING ENVIRONMENT
Generally, we use nRFgo Studio software to programming NRF52840, however,
because of the compatibility of JLink driver, which is the driver of programmer of nRF
series. Herein we use CLI to setup developing environment for nRF52840 instead of
nRFgo Studio.
INSTALL KEIL AND RELATED PACK
Download Keil from its website and install. Note that Keil requires license,
otherwise it can only be used to compile codes which is smaller than 256kB.
After installing, you should also install related Packs. The NRF52840 pack was
already included in resources
2
, run NordicSemiconductor.nRF_DeviceFamilyPack.8.17.0
to install it.
INSTALL SEGGER EMBEDDED STUDIO FOR ARM 4.10A
This tool is only required for Bluetooth MESH examples. You can skip this part if
you do not use MESH.
You can download the package from resources and install it without license.
SERIAL DRIVER INSTALL
The Evaluation board has integrated CP2102 module, which is used for TTL to USB
converting. To properly use serial port, you need to install CP2102 driver in your PC. If
you have installed it before, skip this part.
The CP2102 driver is included in resources, choose one according to your OS.
2
You can find them on Waveshare Wiki: https://www.waveshare.com/wiki/NRF52840_Eval_Kit

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 8/ 72
⚫Double-click installer “CPCP210xVCPInstaller_xxx” to run it
⚫Clock next to finish installing
After installing, you can find that a new serial device is recognized under
Computer->Manager->Devices Manager-> COM and LPT after you connect the
evaluation board to PC.
INSTALL JLINK DRIVER
JLink programmer is used to programming NRF52840. It can also be used to erase
NRF52840Flash and upload Bluetooth Softdevices
3
with nRF5x-Command-Line-Tools.
We recommend you use V6.22 version or above, otherwise, the driver may cannot be
recognized. The JLink driver is included in resources, you can search and download it.
If you have installed Keil before JLink driver, don’t forget to check the option to
cover it as below:
3
Softdevices are protocol stacks for nRF series

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 9/ 72
INSTALL NRFX-COMMAND-LINE-TOOLS
The tool can be downloaded from resources. Download and install it. After
installing, open console, and input nrfjprog -v to check the tools. It should be as below
if you install the tool successfully.
INSTALL APP
App should be installed in mobile phones for debugging.
nRF Connect: Common debugging tool of mobile phone. With this APP, use can
get the original data. nRF Connect can display RSSI curve, supports multiply slave
devices, has high compatibility and is commonly used.
nRF Toolbox: BLE tool. Toolbox is generally used for part of experiments, it has
GUI like thermometer, cardiotachometer. However, it can only be used for some of
experiments and it is not much stable.

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 10 / 72
PERIPHERALS DEMO
Finish the developing environment setup, you now can try with some demo. Herein
using the newest SDK(SDK 15.2), which support Bluetooth 5.0
There are examples in SDK, which can be divided to two kinds, one of them can
run without Softdevice and another are based on Softdevice. The demo which does
not need Softdevice generally located in
nRF5_SDK_15.2.0_9412b96\examples\peripheral\
HARDWARE CONNECTION
⚫Connect J-Link programmer to NRF52840 Eval kit and PC
⚫Connect NRF52840 Eval Kit to PC or other external power adapter
⚫Pull the jumper of LED3, and wire L3 to P1.05
4
4
LED3 isn’t compatible with official SDK, so we should re-connect it when test Blinky sample

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 11 / 72
DOWNLOAD SAMPLES WITHOUT SOFTDEVICE
We take Blinky as example, learn how to use peripherals examples of SDK. Click
blinky->pca10056->blank->arm5_no_packs->blink_pca10056.uvoptx to open the
project. Compiling it:
Generally, it can be compiled successfully without error or warning. After
compiling, you should configure it:
Click Debug, choose J-Links/J-Trace Cortex as debugger. Debug->Settings set
Port to SW

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 12 / 72
Then click Flash Download, check the options as below and confirm by clicking
OK.

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 13 / 72
DOWNLOAD SAMPLES WITH SOFTDEVOCE
Different with samples like the blinky, you should first download softdevices,
which Bluetooth demo codes are based on. Herein we take app_uart as example to
show you how to program such demos.
⚫First, we need to erase NRF52840 flash: Open CMD, connect NRF52840 to PC and
using ARM Debugger(JLink) for programming. Type command to erase NRF52840

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 14 / 72
as below:
⚫Download Softdevice. Click
nRF5_SDK_15.2.0_9412b96->examples->ble_peripheral->ble_app_uart->pca10056
->s140->arm5_no_packs-> ble_app_uart_pca10056_s140.uvprojx to open the
project. Choose flash_s140_nrf52_6.1.0_softdevice:
⚫Download the application code like blinky sample.

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 15 / 72
CHAPTER 3. CREATING NEW PROJECT
SDK should be used for NRF52840 developing, we take common SDK
5
as example
to show you how to create a project.
The SDK used herein is SDK V15.2, there is also template for reference:
nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral\ble_app_template\pca10056\s140
\arm5_no_packs\ble_app_template_pca10056_s140.uvprojx
PROJECT TEMPLATE
Generally, the project should include:
⚫DRIVER: Drivers of hardware peripherals are saved in this directory, like driver of
MPU6050 created by users
⚫SDK: SDK files copied from official SDK, like:
5
There are specific SDK used for Zigbee, Thread and Mesh sevices

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 16 / 72
There are so many files included in SDK, and we only use some of them for certain
project. Most of libraries are included in components, external contains third party
libraries like freertos library and so on. Old drivers are saved to folder integration
and modules contains the new drivers.
⚫TEMP: Intermediate files generated while compiling. The files in this folder can be
deleted.
⚫USER: User files
Generally, files in folders SDK, DRIVER and TEMP are same for different project, what
we need to do is create user files and save them to USER.
CREATE A NEW PROJECT
Create a directory to save project files and copy libraries files to it.
You can google about how to create a new Keil project. Herein we take about
some notices when creating new project.

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 17 / 72
⚫The drivers of user peripherals should be saved in DRIVER folder
⚫The projects created should be saved under USER, and please notice the project
name
⚫The application files are usually saved under the path: USER/[Project
file]/APPLICATION/

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 18 / 72
⚫The Keil project file is saved in IDE folder
⚫Save OBJ files to TEMP folder

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 19 / 72
⚫You had better set the project tree same as official projects.
⚫Notice the PACK version you use, make sure it is same as official examples
For more details, please refer to official examples.

NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 20 / 72
CHAPTER 4. CONTROLING LED
In this chapter, we will instruct how to configure GPIO and control LED. The
examples used herein is 001_LED.
CODES
Open led.h files, you can find that the GPIO and related control functions are defined
in this header file:
#ifndef __LED_H__
#define __LED_H__
#include "nrf.h"
#include "nrf_gpio.h"
#define LED0 NRF_GPIO_PIN_MAP(0,13)
#define LED1 NRF_GPIO_PIN_MAP(0,14)
#define LED2 NRF_GPIO_PIN_MAP(0,19)
#define LED3 NRF_GPIO_PIN_MAP(0,16)
void LED_On(uint32_t led_number);
void LED_Off(uint32_t led_number);
#endif
Functions defined in header file will be realized in led.c file:
#include "led.h"
void LED_On(uint32_t led_number)
{
nrf_gpio_cfg_output(led_number);
nrf_gpio_pin_clear(led_number);
}
void LED_Off(uint32_t led_number)
{
nrf_gpio_cfg_output(led_number);
nrf_gpio_pin_set(led_number);
}
LED_On(led_number): Turn the LED on
LED_Off(led_number): Turn the LED off
Table of contents
Other Waveshare Motherboard manuals