The Ultimate Bluetooth Mesh Tutorial (Part 7)

In today’s tutorial:

  • We’ll first take a step back and talk a little bit about interoperability and compatibility in Bluetooth mesh.
  • Then, we’ll go through a demo of setting up a mesh network that includes a mix of off-the-shelf devices.
  • Finally, we’ll go through the source code step-by-step and the changes needed to implement the functionality for this demo.

Compatibility and Interoperability

The power of having a standard like Bluetooth mesh that a certified device must comply to is:

  • The ability to add devices from different manufacturers to any mesh network.
  • The ability within the network for devices to interact with others that implement a common functionality in an almost seamless manner.

This gives both manufacturers and consumers great flexibility in three main aspects:

  • Choosing the types of devices to be used within a mesh network, including the software applications that may be implemented on devices like tablets and mobile phones that interact with the network (e.g. Provisioner devices).
  • Freedom for the manufacturers to provide a wide variety of devices that provide different functionalities.
  • Flexibility for the end-user in configuring the network to their preference.

The concept of models, which we discussed in Part 2 of this tutorial series (found here), in addition to group addresses help in providing this flexibility.

Consumer Bluetooth Mesh Devices

I’ve been searching the market for devices, specifically light bulbs, that are Bluetooth mesh certified. I came across the following public list of mesh-certified devices, but 99% of the products listed are modules or chipsets.

It was a struggle finding a real consumer product that anyone can buy and use right away. This is understandable (I guess) since the standard is so new.

I saw the listing for LEDVANCE, which turns out is the company behind the Sylvania brand. I reached out to them Twitter, and they were able to point me in the right direction. Finally, I landed on the Sylvania SMART+ light bulbs. I bought a few of them to start building a Bluetooth mesh network in my home, but to also see how easy/hard it would be to create a network from multiple devices from different companies.

A Bluetooth Mesh Lighting Network in the Home

Compatibility and interoperability between certified devices is key to the success of any connectivity standard. My experience so far with this aspect of Bluetooth mesh has been great.

Following is a diagram of a simple Bluetooth mesh network I started building. I have since expanded the number of devices within the network and will be testing it more extensively, especially for reliability and range.

Figure 1: Bluetooth mesh lighting network

The network consists of the following:

  • An iOS or Android provisioner device running a generic Bluetooth mesh provisioner application (such as the Nordic’s nRF Mesh app or Silicon Labs’ Bluetooth Mesh app).
  • Two off-the-shelf Bluetooth mesh-certified light bulbs from Sylvania:
  • A Nordic nRF52840 Development Kit (DK) as a light switch. The light switch implementation will be an adapted version of the example provided by Nordic in the nRF5 SDK for Mesh (which we tested in Part 5), but with some added functionality:
    • Button #1: Turn on F1. Also turns on LED #1 on the development kit.
    • Button #2: Turn on C1. Also turns on LED #2 on the development kit.
    • Button #3: Turn on both F1 and C1 (as a group). Also turn on LEDs #1 and #2 on the development kit.
    • Button #4: Turn off both F1 and C1 (as a group). Also turn off LEDs #1 and #2 on the development kit.
Node Addresses
Figure 2: Node address assignments

nRF52-based Mesh Light Switch (Remote Control)

Make sure you follow the installation and setup steps in Part 5 first.

The original LightSwitch application provided in the nRF Bluetooth mesh examples only supports two Generic OnOff clients. In our example, we need to implement three clients:

  • One Generic OnOff client for controlling F1.
  • One Generic OnOff client for controlling C1.
  • One Generic OnOff client for controlling the group (F1 + C1).

Let’s go through the source code changes to accomplish this.

Step 1: Change the number of clients (from 2 to 3)

The number of clients is defined in the header file nrf5_SDK_for_Mesh_v2.2.0_src/examples/light_switch/include/light_switch_example_common.h .

Change it to 3 (instead of 2):

/** Number of On-Off client models on the Switch Node */

Step 2: Change the behavior of the development kit onboard buttons and LEDs

All the changes we need to make are in the function static void button_event_handler(uint32_t button_number).

  • Change the state set by the button presses to be on for buttons 1,2, and 3. Off for button 4.
        /* Button 1: LED 1 ON, Client[0]
         * Button 2: LED 2 ON, Client[1]
         * Button 3: LEDs 1+2 ON, Client[2]
         * Button 4: LEDs 1+2 OFF, Client[2]
            case 0:
            case 2:
            case 1:
                set_params.on_off = APP_STATE_ON;
            case 3:
                set_params.on_off = APP_STATE_OFF;
  • Modify to have button 2 send a message as client #2 (indexed at 1). Also, make the change to turn on LED 2 (indexed at 1).
            case 1:
                /* Demonstrate acknowledged transaction, using 1st client model instance */
                /* In this examples, users will not be blocked if the model is busy */
                status = generic_onoff_client_set(&m_clients[1], &set_params, &transition_params);
                hal_led_pin_set(BSP_LED_1, set_params.on_off);
  • Modify to have buttons 3 and 4 to send a message as client #3 (indexed at 2). Also, make the change to set the state of both LEDs 1 & 2 (indexed at 0 & 1 respectively).
            case 2:
            case 3:
                /* Demonstrate un-acknowledged transaction, using 2nd client model instance */
                /* Demonstrate acknowledged transaction, using 1st client model instance */
                /* In this examples, users will not be blocked if the model is busy */
                status = generic_onoff_client_set(&m_clients[2], &set_params, &transition_params);
                hal_led_pin_set(BSP_LED_0, set_params.on_off);
                hal_led_pin_set(BSP_LED_1, set_params.on_off);

Provisioning and Network Setup Walkthrough

Let’s go through the different steps for provisioning the nodes and setting up the network from scratch.

Step 1: Make sure all devices are reset and unprovisioned

  • For the nRF52 development board, you can do this by navigating to the Target menu in SES, then choosing Connect J-Link, then Erase All. Once you’ve erased the development board (which may take a minute or two), you can now flash it with the updated Light Switch Proxy Client example that we modified in the previous section.
  • For the Sylvania light bulbs, you can do this by turning off power and then back on 5 times in a row. The last (5th) time you turn the light on, you should see a brief delay (up to 3 secs) after which the light will flash a few times indicating it is now reset.

Step 2: Use the nRF Mesh iOS or Android app to search for devices to provision them

  • Launch the nRF Mesh app and go to the Scanner tab

    Figure 3: Searching for devices (all devices unprovisioned)

Step 3: Provision the different devices

  • Click on each device and Identify it:
    Figure 4: Identify the device

    Figure 5: Identifying the device
  • Provision the device:
    Figure 6: Provision the device

    Figure 7: Provisioning process in progress
  •  You should now see the following screen after provisioning the nRF52 board:
    Figure 8: nRF52 dev kit provisioned


  • Repeat the process for each of the light bulbs. In the end, you should see the following:

    Figure 9: All devices provisioned

Step 4: Configure the Clients and Servers

Now that we have all the devices provisioned, we need to configure the different clients and servers.

  • First, configure the light switch (nRF52x Mesh Switch). Click on the device in the Network view:

    Figure 10: nRF5x Mesh Switch main view
  • We will configure the Generic OnOff Clients as follows:
    • Element 1:

      Figure 11: Generic OnOff Client #1
    • Element 2:

      Figure 12: Generic OnOff Client #2
    • Element 3:

      Figure 13: Generic OnOff Client #3
    • Once you’ve finished, you should see the following in the main view of the nRF5x Mesh Switch Node:

      Figure 14: nRF5x Mesh Switch Configured
  • We’ll configure the Generic OnOff Servers as follows:
    • Configure the SYLVANIA A19 F-M as follows:

      Figure 15: Sylvania Filament light bulb Generic OnOff Server configuration
    • Configure the SYLVANIA A19 C-M as follows:

      Figure 16: Sylvania Full-Color light bulb Generic OnOff Server configuration

Step 5: Test the Bluetooth Mesh Network

Now we’re ready to start the actual test of the networking. Here’s a video showing the testing:

Full Video Tutorial for Provisioning, Configuring, and Testing

If you’d like to follow the steps for provisioning, configuration, and testing through a video, you can do so here:


In the following posts, we’ll do some extensive testing with the Bluetooth mesh network:

  • Adding more lights and other mesh devices.
  • Testing with network range and how adding devices and removing them affects the range.

Don’t forget to enter your email below to stay up-to-date on the latest BLE news as well as be notified when new blog posts and tutorials get published.

Don't miss out on the latest articles & tutorials. Sign-up for our newsletter today!

Take your BLE knowledge to the next level.

If you’re looking to get access to full video courses covering more topics, then check out the Bluetooth Developer Academy.

As part of all the courses within the Academy, you’ll also be able to download the full source code to use as a reference or use within your own application.

By joining the Bluetooth Developer Academy, you will get access to a growing library of video courses (one course released every single month).

The Academy also features access to a private community of Bluetooth experts, developers, and innovators. You’ll get to connect and interact with me and other experts in the Bluetooth space, learn from others’ experiences and knowledge, and share yours as well.

So, what are you waiting for?? Join today!

You may also be interested in these articles.

Don't miss out on the latest articles & tutorials. Sign-up for our newsletter today!

Want to quickly learn the core basics of Bluetooth Low Energy?

Grab a copy of my FREE “Intro to Bluetooth Low Energy” e-book now!