Bluetooth Mesh: Silvair EnOcean

You can use the Bluetooth Mesh Silvair EnOcean sample to change the state of light sources on other devices within the same mesh network. It also demonstrates how to use Bluetooth® Mesh models by using the Silvair EnOcean Proxy Server model in an application.

Use the Silvair EnOcean sample with the Bluetooth Mesh: Light fixture sample to demonstrate its function in a Bluetooth Mesh network.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Board target

nRF54L15 DK

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l15/cpuapp

nRF5340 DK

PCA10095

nrf5340dk

nrf5340dk/nrf5340/cpuapp/ns nrf5340dk/nrf5340/cpuapp

nRF52 DK

PCA10040

nrf52dk

nrf52dk/nrf52832

nRF52840 DK

PCA10056

nrf52840dk

nrf52840dk/nrf52840

nRF52833 DK

PCA10100

nrf52833dk

nrf52833dk/nrf52833

nRF21540 DK

PCA10112

nrf21540dk

nrf21540dk/nrf52840

You need at least two development kits:

  • One development kit where you program this sample application (Silvair EnOcean Proxy Server model, including the Generic OnOff Client and the Generic Level Client)

  • One (or more) development kit(s) where you program the Bluetooth Mesh: Light fixture sample application (the server(s)), and configure according to the mesh light fixture sample’s testing guide

For provisioning and configuring of the mesh model instances, the sample requires a smartphone with Nordic Semiconductor’s nRF Mesh mobile app installed in one of the following versions:

When built for a board target with the */ns variant, the sample is configured to compile and run as a non-secure application with Cortex-M Security Extensions enabled. Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.

Overview

The Bluetooth Mesh Silvair EnOcean sample demonstrates how to set up mesh client model applications, and control LEDs with the Bluetooth Mesh using the Generic OnOff models and Generic Level models with use of an EnOcean switch. To display any functionality, the sample must be paired with a device with the Bluetooth Mesh: Light fixture sample running in the same mesh network.

In both samples, devices are nodes with a provisionee role in a mesh network. Provisioning is performed using the nRF Mesh mobile app. This mobile application is also used to configure key bindings, and publication and subscription settings of the Bluetooth Mesh model instances in the sample to enable them to communicate with the servers.

The Generic OnOff Client model and the Generic Level Client model are used for manipulating the Generic OnOff state and Generic Level state associated with the Generic OnOff Server model and Generic Level Server model respectively. The Silvair EnOcean sample implements the Silvair EnOcean Proxy Server model that instantiates the Generic OnOff Client and the Generic Level Client models.

The sample uses a two (or one) button EnOcean switch to control the state of LED 1 on servers (implemented by the Bluetooth Mesh: Light fixture sample). Two instances of the Generic OnOff Client model and two instances of the Generic Level Client model are instantiated in the Silvair EnOcean sample, one of each model for each button on the EnOcean switch that is used. When a user presses or holds any of the buttons on the EnOcean switch, an OnOff/Level Set message is sent out to the configured destination address.

After provisioning and configuring the mesh models supported by the sample using the nRF Mesh mobile app, you can control the LEDs on the other (server) development kit(s) from the app.

Provisioning

Provisioning is handled by the Bluetooth Mesh provisioning handler for Nordic DKs. It supports four types of out-of-band (OOB) authentication methods, and uses the Hardware Information driver to generate a deterministic UUID to uniquely represent the device.

Models

The following table shows the mesh Silvair EnOcean composition data for this sample:

Element 1

Element 2

Config Server

Gen. Level Client

Health Server

Gen. OnOff Client

Gen. DTT Server

Gen. Level Client

Gen. OnOff Client

Silvair EnOcean Proxy Server

The models are used for the following purposes:

  • The Silvair EnOcean Proxy Server instantiates Generic OnOff Client and Generic Level Client on both elements, where each element is controlled by the buttons on the EnOcean switch.

  • Generic Default Transition Time Server is used to control transition time of the Generic OnOff Server instances.

  • Config Server allows configurator devices to configure the node remotely.

  • Health Server provides attention callbacks that are used during provisioning to call your attention to the device. These callbacks trigger blinking of the LEDs.

The model handling is implemented in src/model_handler.c, which uses the DK Buttons and LEDs library to detect button presses on the development kit.

The response from the target device updates the corresponding LED on the mesh Silvair EnOcean device. When the target device is turned on or off, the corresponding LED will turn on or off accordingly. If the light level is increased above BT_MESH_LVL_MIN on the target device, the corresponding LED will turn on. The LED will turn off if the light level is equal to BT_MESH_LVL_MIN.

User interface

Development kit buttons:

During the provisioning process, all buttons can be used for OOB input. Once the provisioning and configuration are completed, the buttons are not used.

EnOcean buttons:

Pressing and releasing the button on the EnOcean switch publishes an OnOff message using the configured publication parameters of its model instance, and toggles the LED state on a mesh light device. Pressing and holding the button on the EnOcean switch publishes a Level message using the configured publication parameters of its model instance, and changes the emitted LED light level on the mesh light device.

LEDs:

During the provisioning process, all LEDs are used to output the OOB actions. Once the provisioning and configuration are completed, the LEDs are used to reflect the status of actions, and they show the last known OnOff/Level state of the corresponding button. It will not change its emitted LED light level, it will only be on or off.

Configuration

See Configuring and building for information about how to permanently or temporarily change the configuration.

For nRF5340 and Thingy:53, the extended advertiser has to be set manually for the network core, because the Bluetooth® Low Energy does not know that the Bluetooth Mesh is enabled when built for this core. This is already done for this sample by setting CONFIG_BT_EXT_ADV=y for the network core.

Source file setup

The Silvair EnOcean sample is split into the following source files:

  • A main.c file to handle initialization.

  • One additional file for handling mesh models, model_handler.c.

FEM support

You can add support for the nRF21540 front-end module to this sample by using one of the following options, depending on your hardware:

  • Build the sample for one board that contains the nRF21540 FEM, such as nrf21540dk/nrf52840.

  • Manually create a devicetree overlay file that describes how the nRF21540 FEM is connected to the SoC. See Configuring devicetree for different ways of adding the overlay file.

  • Provide nRF21540 FEM capabilities by using a shield, for example the nRF21540 EK shield that is available in the nRF Connect SDK. In this case, build the project for a board connected to the shield you are using with an appropriate variable included in the build command, for example -DSHIELD=nrf21540ek. This variable instructs the build system to append the appropriate devicetree overlay file.

    To build the sample in the nRF Connect for VS Code extension for an nRF52840 DK with the nRF21540 EK attached, add the shield variable in the build configuration’s Extra CMake arguments and rebuild the build configuration. For example: -DSHIELD=nrf21540ek.

    See How to work with build configurations in the nRF Connect for VS Code extension documentation for more information.

    See Programming nRF21540 EK for information about how to program when you are using a board with a network core, for example the nRF5340 DK.

Each of these options adds the description of the nRF21540 FEM to the devicetree. See Developing with Front-End Modules for more information about FEM in the nRF Connect SDK.

To add support for other front-end modules, add the respective devicetree file entries to the board devicetree file or the devicetree overlay file.

Building and running

Make sure to enable the Bluetooth Mesh in nRF Connect SDK before building and testing this sample. See Bluetooth Mesh user guide for more information.

This sample can be found under samples/bluetooth/mesh/silvair_enocean in the nRF Connect SDK folder structure.

When built as firmware image for a board target with the */ns variant, the sample has Cortex-M Security Extensions (CMSE) enabled and separates the firmware between Non-Secure Processing Environment (NSPE) and Secure Processing Environment (SPE). Because of this, it automatically includes the Trusted Firmware-M (TF-M). To read more about CMSE, see Processing environments.

To build the sample, follow the instructions in Building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.

Note

When building repository applications in the SDK repositories, building with sysbuild is enabled by default. If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild parameter to every build command or configure west to always use it.

Testing

Note

The Silvair EnOcean sample cannot demonstrate any functionality on its own, and needs a device with the Bluetooth Mesh: Light fixture sample running in the same mesh network.

After programming the sample to your development kit, you can test it by using a smartphone with nRF Mesh mobile app installed. Testing consists of provisioning the device and configuring it for communication with the mesh models.

Provisioning the device

The provisioning assigns an address range to the device, and adds it to the mesh network. Complete the following steps in the nRF Mesh app:

  1. Tap Add node to start scanning for unprovisioned mesh devices.

  2. Select the Mesh Silvair EnOcean device to connect to it.

  3. Tap Identify, and then Provision, to provision the device.

  4. When prompted, select an OOB method and follow the instructions in the app.

Once the provisioning is complete, the app returns to the Network screen.

Configuring the EnOcean switch

See Commissioning for details on how to configure the EnOcean switch.

Configuring models

See Configuring Bluetooth Mesh models using the nRF Mesh mobile app for details on how to configure the mesh models with the nRF Mesh mobile app.

Configure the Generic OnOff Client and the Generic Level Client models on each element on the Mesh Silvair EnOcean node:

  • Bind the model to Application Key 1.

  • Set the publication parameters:

    • Destination/publish address: Set the Publish Address to the first unicast address of the Mesh Light Fixture node.

Note

Configuring the periodic publication and publication retransmission of these models has no effect.

Once the provisioning and the configuration of the client node and at least one of the server nodes are complete, you can use buttons on the EnOcean switch. The buttons will control the LED lights on the associated servers, as described in User interface.

Dependencies

This sample uses the following nRF Connect SDK libraries:

In addition, it uses the following Zephyr libraries:

The sample also uses the following secure firmware component: