Maker.io main logo

Getting Started With Thread Networking Using Silicon Labs Dev Boards

2023-04-17 | By ShawnHymel

License: Attribution

Thread is a wireless networking protocol designed for low-power and low-datarate Internet of Things (IoT) and smart home devices. It is built on top of the IEEE 802.15.4 wireless standard that operates on the 780 MHz (China), 868 MHz (Europe), 916 MHz (Americas), 950 MHz (Japan) and 2.4 GHz (ISM) channels. The 802.15.4a amendment allows for ultra-wideband operation in the sub-1 GHz, 3-5 GHz, and 6-10 GHz ranges.

Thread networks consist of routers and end devices. Routers can mesh and self-heal to create a robust network with wide coverage. End devices connect to the routers and have the option of disabling their radios to save on power. 

I highly recommend watching this video to learn more about how Thread works:

 

This tutorial will walk you through the process of setting up a simple Thread network using two development boards with Silicon Labs (SiLabs) microcontrollers and pinging each device using the OpenThread command line interface (CLI).

Required Hardware

To complete this demo, you will need two Thread-capable development boards from Silicon Labs. Any number of boards using the EFR32MGxx chipset will work, but I recommend either the SiLabs xG24-DK2601B or the SparkFun Thing Plus Matter board. I will use one of each in this demo.

SiLabs and SparkFun development boards for Thread

Configure Simplicity Studio

To start, download and install Simplicity Studio from here: https://www.silabs.com/developers/simplicity-studio. Note that you will need to create an account on the Silicon Labs site. Accept all the defaults and agreements during the installation process.

When the installation is done, you will be prompted for your login credentials. Go ahead and enter your SiLabs username and password. This will cause the Studio to install drivers–accept all defaults and agree to install the drivers.

Once done, plug in one of your development kits to your computer. I’ll start with the EFR32xG24 Dev Kit. You should see a pop-up that asks you to install the Device Inspector.

Install device inspector

Click Yes. Accept all defaults during the installation process.

You should see the Installation Manager window. If you do not see this pop-up, select Help > Update Software

Simplicity Studio Installation Manager

With the board still plugged in, select Install by connecting device(s). You should see the Installation Manager ask you to select a product. For the EFR32xG24, you should have the EFR32xG24 Dev Kit Board option selected. Click Next. You should then be asked to select a package option.

Simplicity Studio package installation options

Select Auto and click Next. On the following screen, accept the agreements and click Next to install the software development kits (SDKs) for that particular board. When it is done, you will be asked to restart the Studio. Accept any license agreements you see after the restart.

Flash the Full Thread Device (FTD)

We’ll start by flashing the FTD to our ERF32xG24 board. This device will act as our router and Thread Leader. 

Select File > New > Silicon Labs Project Wizard… You should see the following options selected for your board. Note that you must have the Geck SDK Suite selected for your SDK and Simplicity IDE / GNU ARM selected for the IDE / Toolchain.

Simplicity Studio SDK and toolchain selection

Select Next. Click Thread to filter by that technology. Scroll down in the example list and select OpenThread - SoC CLI (FTD). This is a simple command-line interface FTD example based on the OpenThread FTD example here.

Select example Thread project in Simplicity Studio

Click Next. Change the name of the project (if you wish). I’ll call mine “thunderboard-sense-2-ot-cli-ftd” to make it match the video. Leave the other options as their defaults.

Name project in Simplicity Studio

Click Finish. The Simplicity IDE perspective should open. Under your project on the left-side pane, feel free to click main.c to examine the source code. Click the project name or any file in your project in the left-side Project Explorer pane and select Project > Build Project. This will build your project.

Build project in Simplicity Studio

In the left pane again, expand Binaries under your project. Right-click on <project-name>.s37 and select Flash to Device.

Select flash device in Simplicity Studio

You should be presented with the Flash Programmer window.

Flash programmer window in Simplicity Studio

Click Program. When done, click Close. Feel free to check the Console log in Simplicity Studio to make sure there were no errors. 

Programming complete in Simplicity Studio

If there were no errors, your FTD is ready to go!

Flash the Minimal Thread Device (MTD)

The MTD acts as our child node (end device) that can talk to our FTD router. Unplug your first board and plug in your other board. Repeat the steps above to install the drivers (if it is different from the first board). For example, I will use my SparkFun Thing Plus Matter board for the MTD, but you are welcome to use any other Thread-supported SiLabs board (e.g. another EFR32xG24 Dev Kit Board).

Plug in your board with Simplicity Studio open. Agree to install any drivers as required. Select File > New > Silicon Labs Project Wizard… Make sure your new board (e.g. SparkFun Thing Plus MGM240P) is selected for the Target Board and the appropriate microcontroller/SoC (e.g. MGM240PB32VNA for the SparkFun board) is selected for the Target Device. Check that you have the Gecko SDK and Simplicity Studio / GNU Arm selected for the last two options.

Select target SDK and toolchain in Simplicity Studio

Select Next. Filter by Thread and select the OpenThread - SoC CLI (MTD) example. This demo is based on the OpenThread MTD example here.

Select OpenThread MTD example in Simplicity Studio

Click Next. Give your project a name (e.g. sparkfun-thing-plus-ot-cli-mtd) and click Finish.

In the Simplicity IDE, click on the MTD project and select Project > Build Project. Assuming you have no errors, right-click on <project-name>.s37 under Binaries in your project. Select Flash to Device. In the Flash Programmer window, click Program.

Flash MTD example to board from Simplicity Studio

Check the logs in the console to make sure you have no errors.

Ping Both Thread Devices

Now that we have both Thread devices flashed, we can use the CLI (built in to the firmware of each device) to create a Thread network and have the devices ping each other. This demonstration is shown in the video.

Open a serial terminal (e.g. using PuTTY if you are on Windows) to each of the devices using a baud rate of 115200 and 8-N-1 settings. Pay attention to which is your FTD and which is your MTD! Only the FTD can create a Thread network and become a Thread leader. In the screenshots, the FTD is COM5 on the left and the MTD is COM9 on the right.

In the FTD serial terminal, enter the following commands. Note that I have described what each of the commands does to help you understand how you are creating a Thread network. The full set of OpenThread commands can be found here.

  • dataset init new - Create new network configuration (called a “dataset”)
  • dataset commit active - Commit the dataset to non-volatile storage
  • ifconfig up - Enable Thread interface
  • thread start - Join the network (wait ~10 sec for device to join)
  • state - Check state of current node (should be “leader”)
  • dataset - Check network configuration
  • ipaddr - View all IPv6 addresses
  • ipaddr mleid - Get MLEID address only–this is the one we care about when creating applications or pinging

Note that you need to wait at least 10 seconds after the thread start command to let the network configuration finish. The state command will show “detached” until the network configuration is done. Only once you see the “leader” status from the state command should you continue.

In the end, you should have the Mesh-local Endpoint Identifier (ML-EID) IP address of the FTD, which is the address we need to uniquely identify and talk to this particular endpoint. You can learn more about IP addressing for Thread here.

CLI commands for OpenThread FTD router

In the MTD serial terminal, enter the following commands:

  • dataset channel <n> - Set <n> to channel given by leader (see output from above)
  • dataset networkkey <key> - Set <key> by copying in the network key from the output above (this acts as a password to join the network)

Note that you need to copy the Channel and Network Key from the leader’s output. These tell the MTD how to attach to and communicate on the network that we set up using the FTD.

Configure OpenThread MTD in CLI

From there, enter the following commands:

  • dataset commit active - Commit the dataset to non-volatile storage
  • ifconfig up - Enable Thread interface
  • thread start - Join the network (wait ~10 sec for device to join)
  • state - Check the state of the current node (should be “child”)
  • dataset - Check network configuration (node is not the leader, so there will be less info)
  • ipaddr - View all IPv6 addresses
  • ipaddr mleid - Get MLEID address of child

Once again, you need to wait at least 10 seconds after calling thread start to let the MTD connect to the network. From there, the state command should report “child.” When you call the ping command, give it the MLEID IP address of the other device.

  • ping <mleid-ipaddr-of-other-device> - Send a ping to <mleid-ipaddr-of-other-device> and report the response time

Ping OpenThread FTD and MTD using the CLI

You should see the ping succeed from both the FTD and the MTD. If you see that the packets were successfully transmitted and received, then you know that you have flashed the Thread firmware and configured the Thread network correctly!

Going Further

If you would like to learn more about Thread and the Silicon Labs demos, check out the following:

制造商零件编号 XG24-DK2601B
XG24 +10 DBM DEV KIT
Silicon Labs
¥651.45
Details
制造商零件编号 DEV-20270
THING PLUS MATTER MGM240P
SparkFun Electronics
¥203.50
Details
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum