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):

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.
  • 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).
  • 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).

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.


  1. Avatar Prasad on December 7, 2019 at

    Hi Mohammad,

    I am working on the project for the event management where I’m developing the Bluetooth based wearable Badges. While I was trying to build the Mesh for the purpose, I faced challenges in building the solution. As of now I built the PoC using the ready Mesh from Particle Mesh kit. But still facing some challanges. Hence I need your expert opinion on how to build the following mentioned use cases with right approach of architecture. The details are given below :

    All Beacons should be in the BLE mesh network with connectivity to the cloud gateways (Wifi Type) at certain distance with repeaters/relay nodes at every 100 meters.​

    Beacon should have 1) Single Push button and 2) 3 RGB LED (Normal RGB or WS2812) – Low power​

    Beacon should be Coin Cell powered with CR3032 3V 500mAh or CR2032​

    Each beacon should advertise in two pattern –​

    1. Heart beat Message (ID, Tx Power, RSSI, Battery % ) with x time interval to the gateway/beacon scannerCloud – for the real time indoor tracking/Zone specific Heat maps​

    2. Based on Switch event- when the user is pressing the switch on both beacons closed to each other (within 6 inch of distance) – based upon the proximity detection it should advertise and exchange the data to each other and based on the connectivity to the gateway, it should publish the data to the MS Azure IoT Hub. (should require EEPROM storage to store the data temporarily until publish to the cloud).​

    There should be Publish-Subscribe method from Gateway to all beacons to broadcast the common message to blink the LED with custom colours.​

    Message Customization : User should have the API to select the ID’s of the Beacons to whom they want to send the messege (color code) of the LED to blink.​

    Message Routing: Cloud (Azure IoT hub) -> All the gateways -> Connected beacons to the gateway

    For the reference please see the link below :

  2. Avatar KaliU on December 7, 2019 at

    Please, more tutorials like these. Great.

  3. Avatar Juan Vázquez on March 1, 2019 at

    Hello, thank you for the information!
    I have a question: there is a way to configure the ligh_switch/privisioner.c code to do the same as the example?
    I mean, to use a board to do dynamic provisioning instead of a cellphone, but configuring the code to have 3 groups.

  4. Avatar Hitesh Mankar on December 18, 2018 at

    Thanks for tutorial. It really helped to implement light_switch practical.
    I’m trying to build Bluetooth mesh network using nRF52840 to transfer the sensor data to the server/(node at far end).

    The main problem I am facing is, how to relay the message/signal from 1 node to other node and to end node.

  5. Avatar POH on December 10, 2018 at


    Thanks for your blog post. I stumbled across it when I was searching for the LEDVANCE product which was listed on the SIG certification list.

    I have tried different methods of contacting LEDVANCE to ask if it is possible to reflash an OSRAM Apple Home Kit bulb as you did with the SYLVANIA bulb, but they never answered. Since I’m in Sweden I was hoping I could buy an OSRAM 230 V product but in the end I arranged to get a SYLVANIA 110 V bulb from Amazon.

    I too am developing using the Nordic SDK. Now that I have my bulb I can successfully use the Generic OnOff Client. However I have problems using the Light HSL models. The Mesh Model Specification for instance says that Light HSL Set takes two bytes each for Lightness, Hue and Saturation. To me it seems that the bulb only accepts values in the range of 0–99 instead of 0x0000–0xFFFF. Have you tried this?

    Would you mind sharing contact info for the support people you got help from at LEDVANCE? Offline is fine by me 🙂


    • Mohammad Afaneh Mohammad Afaneh on December 11, 2018 at

      Hi Pär-Olof,

      I remember trying to interact with the HSL model, but I had problems and was not able to figure it out.

      I went through official support at first (through Twitter like I saw you did), but then they got me connected with someone in technical support. I’ll reach out to him and see if he doesn’t mind me sharing his contact info with you. I’ll get back to you via email.


      • Avatar P-O Håkansson on December 14, 2018 at

        Hi again

        I thought there was no hope of getting any reply from SYLVANIA, so I figured it out on my own 🙂

        Here’s a Light HSL set for orange as an example:

        0x8276/0x8277 0100 1500 6400 xx 02 00

        0100: Lightness
        1500: 0-359 degrees in Hue/Saturation color wheel
        6400: 0-100 saturation
        xx: transaction Id, the bulb doesn’t seem to care
        02: transtion time
        00: delay

        It’s not easy being an early adopter 🙂


        • Mohammad Afaneh Mohammad Afaneh on December 17, 2018 at


          Thanks so much for sharing! I will give it a try.


    • Avatar Rick.Chou on March 27, 2020 at

      hi POH :

      Did you have success in the OSRAM Apple Home Kit bulb change to BT Mesh??

      Best Reagrds,


  6. Avatar Roe on November 26, 2018 at

    Sorry for the delay. I mean that i want to set up a mesh network using the nRF52840 chips (9 of them). As such they will be the nodes (or relays instead of the ‘routers’ term).

    • Mohammad Afaneh Mohammad Afaneh on November 27, 2018 at

      Ok, makes sense. There should be a variable/field to set the maximum number of hops a mesh message should take (which basically enables multi-hopping). I’ll look into the latency measurement part and get back to you.

  7. Avatar Roe on November 14, 2018 at

    Hi. I am trying to build a mesh network using the nRF52840. Your tutorials have made all the complex stuff seem a little easier. I am struggling with setting up my mesh and just sending packets/pings between the routers. I need the mesh to enable multihopping especially in buildings with obstructions. I would also like to collect and analyze latency during the ‘pinging’. How can i do that?

    • Mohammad Afaneh Mohammad Afaneh on November 20, 2018 at

      Hi Roe,

      Can you explain what you mean by “routers”?

  8. Avatar Cliff Brake on November 5, 2018 at

    Great information — nice to learn there is actually a BT mesh bulb on the market now!

    Will be interesting to see how the range testing goes.

Leave a Comment