nRF5 SDK for Thread and Zigbee v3.0.0
Thread CLI Example

Table of Contents

The Thread CLI example demonstrates a minimal OpenThread application that enables user interaction through built-in command line interface (CLI). It can be used as a base for more sophisticated applications. This example has similar functionality as the CLI example available in the official OpenThread repository but has been adopted to use with the nRF5 SDK. For additional information about the example, refer to OpenThread CLI Example.


See the following table for the overview of the available CLI example configurations.

Configuration Description Stack variant used Available for
FTD UART Uses the UART communication and SEGGER J-Link as a UART-USB converter. Thread FTD PCA10056
FTD USB Uses the USB peripheral that is available in nRF52840 and communicates as a native USB CDC device. Thread FTD PCA10056, PCA10059 (with bootloader, see nRF52840 Dongle)
MTD UART Uses the UART communication and SEGGER J-Link as a UART-USB converter. Thread MTD PCA10056, PCA10068 with nRF52811
MTD USB Uses the USB peripheral that is available in nRF52840 and communicates as a native USB CDC device. Thread MTD PCA10056, PCA10059 (with bootloader, see nRF52840 Dongle)

If the native USB CDC connectivity is used on hosts running on Windows XP or Windows 7, you must manually install the nordic_cdc_acm.inf driver that is located at <InstallFolder>\examples\usb_drivers.

Hosts running on Windows 8 (and later) will automatically pick the correct driver (usbser.sys).

The CLI application starts in disconnected state and remains so until appropriate commands are issued by the user. These commands can be issued by using a serial line connection with a terminal application like PuTTy.

Network state is indicated by BSP_LED_0. When the device is not connected to a network, the LED blinks at a 200-ms period. Once the device connects to a network, either as a Child or as a Leader, the LED stops blinking and remains turned on.

When the application starts, you can configure the network using the following commands:

> panid 0xabcd
> ifconfig up
> thread start

Once the device is connected, you can check its role using the state command:

> state

The actual state may differ, depending on when the device joined the network.

To obtain the IP addresses of a device, run the following command:

> ipaddr

Once there are two or more devices in the network, you can ping one from another with the ping command:

> ping fdde:ad00:beef:0:96dc:d278:c12c:d2de
16 bytes from fdde:ad00:beef:0:96dc:d278:c12c:d2de: icmp_seq=2 hlim=64 time=11ms

For a complete list of CLI commands, run the help command. For complete CLI documentation, refer to OpenThread CLI Reference.


You can find the source code and the makefile in the following folder: <InstallFolder>\examples\thread\cli.


  • To test this example, you need at least two nRF52840 Development Kits or one nRF52840 and one nRF52811 Development Kits.
  • Make sure you disabled the Mass Storage Device and forced Hardware Flow Control in SEGGER J-Link. See Configuring SEGGER J-Link software for details.

To test the example:

  1. Build the example according to the instructions in Building examples.
  2. Program both development kits with the selected CLI application (UART or USB).
  3. Connect to the boards through UART. If UART CLI is used, use the SEGGER J-Link USB port, otherwise use the native nRF USB port. The application uses the following UART settings:
    • Baud rate: 115200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: None
  4. Set up the Thread network on both devices as described in Description (panid, ifconfig, and thread commands). Be sure to set the same PAN ID on both devices.
  5. Wait until both devices are connected to the network (BSP_LED_0 stops blinking).
  6. Check IP addresses on one of the devices.
  7. Ping one of the IP addresses from the other device. You will receive a response from the first device.

Documentation feedback | Developer Zone | Subscribe | Updated