Skip to main content

Bluetooth Mesh Network with Silicon Labs

Create a Smart Home Lighting Demo Using Thunderboard Sense 2 Sensors

 

Silicon Labs Thunderboard™ Sense 2 is a compact multi-sensor and multi-protocol development kit. This kit features a broad range of sensors and is based on the powerful EFR32™ Mighty Gecko Wireless System-on-Chip (SoC). It also includes four high-brightness RGB LEDs. The Thunderboard Sense 2 is an ideal platform for developing battery-operated Internet of Things (IoT) devices. Mighty Gecko supports proprietary stacks and standard protocols such as Zigbee, Thread, and Bluetooth® Low Energy. In this project, we'll set up a Bluetooth mesh network using several Thunderboard Sense 2 boards. Two boards will be provisioned as lights and one as a switch. The Bluetooth mesh smartphone application, developed by Silicon Labs, allows control of either an individual light or group lights. Also, the provisioned devices can control all lights in the same group.

Bluetooth Mesh

Bluetooth mesh is a new topology for Bluetooth Low Energy devices. The technology was released in 2017 to allow many-to-many device communications. Bluetooth mesh enables multi-hop communications between a larger scale of Bluetooth devices, which makes it ideal for applications for smart home, e.g. lighting and wireless sensor nodes. Before Bluetooth mesh, all Bluetooth devices had to be connected to a central hub, known as a 'star-network' topology. That means the nodes in a star-network cannot communicate with each other. Previously, all messages were between a node and central hub. But with a mesh network, all devices can communicate with each other. This allows extending the range of a network with the numbers of nodes in the thousands. (Figure 1).

star network compared to a mesh network

 

Figure 1: Star network compared to a mesh network. (Source: Silicon Labs)

We'll also be building a Bluetooth mesh lighting demo, and I'll go through how communications in a Bluetooth mesh network works.

Provisioning

Devices added to a mesh network must first be provisioned to a mesh network. Provisioning is mainly a security process, where the provisioner discovers the unprovisioned devices and sends an invitation to the device to join the network. Then the provisioner and the device to be provisioned exchange public keys. Each device then generates a session key that will be used to secure the connection to exchange the provisioning data. The provisioning data includes the network key, a device key, a security parameter called the IV index and its unicast address. After this, the unprovisioned device is now called a node in the mesh network.

Publish and Subscribe

The communication mechanism used in Bluetooth Mesh is called Publish and Subscribe. In a Bluetooth mesh network, nodes are usually configured into groups. For example, all lights in a room can be grouped together. This means that all nodes in a group can receive the same message. The functionality of this mechanism is as follows (Figure 2):

  • Subscribe: Nodes as lights are subscribed to a group, i.e. kitchen.
  • Publish: Nodes as switches publish messages to the groups.

In a mesh network, each group is assigned a group address and multicast messaging is used to send messages to all devices.

diagram of the publish and subscribe nodes

 

Figure 2: Publish and Subscribe. (Source: Silicon Labs)

Software Setup

In this demo, I'll use three Thunderboard Sense 2 sensors to demonstrate a basic Bluetooth mesh lighting application. You'll need at least two TBS2 boards to be able to build a mesh network.

Let's start with flashing the demo software for our lighting demo. For this step, you'll need to download Simplicity Studio, the Integrated Drive Electronics (IDE) provided by Silicon Labs.

  1. Install the Bluetooth Mesh SDK:
    Installation manager for installing SDK
     

    Figure 3: Simplicity Studio - Installation manager for installing SDK. (Source: Mouser Electronics)

    Bluetooth package install
     

    Figure 4: Simplicity Studio - Bluetooth package install. (Source: Mouser Electronics)

    • Open Simplicity Studio and sign up or log-in, if you already have an account. You must have a login to access the Bluetooth Mesh SDK.
    • Click on "Help" followed by "Update Software". The installation Manager should appear (Figure 3). Click on "Install by Product Group".
    • Select "Bluetooth" under WIreless & RF (Figure 4)
    • Follow the installation by clicking "Next" and accepting the terms and conditions.
  2. Demo firmware flashing:
    Bluetooth Mesh Demo firmware flashing
     

    Figure 5: Simplicity Studio - Bluetooth Mesh Demo firmware flashing. (Source: Mouser Electronics)

    • Connect the Thunderboard Sense 2 via Micro-B USB to a PC
    • In Simplicity Studio, the board will appear in the left top-side panel under "Debug Adapters". Select it and you should see demo software starting to loading in the Launcher.
    • Under "Demos", open the Bluetooth Mesh SDK. For this project, You'll need to flash two boards with the "SOC - BT Mesh Light" example and one board with the "SOC - BT Mesh Switch" example (Figure 5).

Thunderboard Sense 2 Provisioning

In this step, we're going to provision our devices to a network and group them together. For this step, install the Bluetooth mesh mobile app on a smartphone. The app is available for iOS and Android. After installing the app, open it and create a new network. For this exercise, we created a network called "Demo Smart Home". You can create a new network by clicking the "+" button in the top right corner. If you select the network, you can create new groups. The group will represent a room in a smart home. (Figure 6)

screen of creating a new network and two new groups on the Bluetooth mesh smartphone app

 

Figure 6: Bluetooth mesh smartphone app – Creating a new network and two new groups. (Source: Mouser Electronics)

Provisioning and Configuring a Device as a Light Node:

Click on the "Provision" tab to provision the devices to the network. All the unprovisioned devices will appear in the list. Select the Bluetooth device and click on "Provision". After provisioning, you'll be directed to the Device Configuration page where you'll have the options to change the name of the device, add it to a group and give it functionality. For simplicity, we changed the name of the light node to "Lamp 1". Next, select the group where you’ll add the light node. Finally, select "Light CTL Server" as functionality for the light node. CTL stands for Color Tunable Light, which means that our light node can receive on/off, color temperature, and lightness messages (Figure 7). The same procedure will be done for the second light node.

screen of provisioning and configuring a light node on the Bluetooth mesh smartphone app

 

Figure 7: Bluetooth mesh smartphone app – Provisioning and configuring a new network and two new groups. (Source: Mouser Electronics)

Provisioning and Configuring a Device as a Switch Node:

Go back to the unprovisioned devices list and select a switch node. Follow the same steps for provisioning a light node, but select "Light CTL Client" as functionality for the switch. Instead of receiving messages, as with the light node, the switch node will be publishing events, which means it will be sending on/off, color temperature, and lightness messages. (Figure 8)

screen of provisioning and configuring a switch node on the Bluetooth mesh smartphone app

 

Figure 8: Bluetooth mesh smartphone app – Provisioning and configuring a new network and two new groups. (Source: Mouser Electronics)

Demo

The Bluetooth mesh network is now ready to be tested. The high-brightness LEDs on the Thunderboard Sense 2 boards provisioned as light nodes are used to demonstrate the lamps. The light nodes can be controlled as a group or individually through the Bluetooth mesh smartphone application. To control light nodes through the board that is provisioned as a switch, use the two push-buttons, PB0 and PB1.

PB0 button:

  • Short press: Decrease light lightness by 10%
  • Medium press: Decrease CTL value
  • Long press: Send OFF message

PB1 button:

  • Short press: Increase light lightness by 10%
  • Medium press: Increase CTL value
  • Long press: Send ON message
the two groups setup on the app, and pictures of the light nodes and the boards provisioned as switches

 

Figure 9: Final setup with two groups for demonstration. (Source: Mouser Electronics)

Conclusion

Bluetooth mesh allows many-to-many device communications. All devices can receive and send messages and the network is self-healing, meaning that if a node drops from the network, the other nodes will still work. With many devices connected in a mesh network, larger areas can be covered. The Thunderboard Sense 2 offers designers a quick and easy way to build a Bluetooth mesh network. It also features different environmental sensors on-board and has low-power features, making it an ideal device for battery-operated IoT applications. Silicon Labs offers the open-sourced SDK of the demonstrated Bluetooth mesh lighting application, which will get you easily started in Bluetooth mesh.

About the Author

Rafik Mitry joined Mouser Electronics in 2019 after finishing his Master's degree in Electrical Engineering at the Technical University of Munich, where he also worked in research in the field of energy harvesting for three years. As a Technical Marketing Engineer at Mouser, Rafik creates unique technical content that reflects current and future technology trends in the electronics industry. Besides keeping up with the latest in technology trends, Rafik is an avid lover of aviation and tennis.

Profile Photo of Rafik Mitry