nRF5 SDK for Mesh v4.2.0
Light LC server example
You can test this example on the following devices: nRF52840, nRF52833, and nRF52832.
This example is not compatible with the nRF52810 device.

This example demonstrates how the light controller uses the data coming from sensors and switches to control the lightness level of lights. After configuring and running this example, triggering Light On, Light Off, and occupancy events will change the brightness of the LED on your board.

This examples uses the Light LC Setup Server model. For more information about the Light LC Setup Server model, see also the Bluetooth SIG's Mesh Model Overview.

For provisioning purposes, the example requires either the provisioner example that is provided in the Provisioner example or the nRF Mesh mobile app.

Table of contents

The example instantiates the following models:

The model instance uses the Light On and Light Off events and the data coming from occupancy and ambient sensors to adjust the lightness output, which is used to control the brightness of the LED using the APP_PWM library of the nRF5 SDK.

lc_example_structure.svg
Light LC server example structure

This example has the provisionee role in the network. It supports provisioning over Advertising bearer (PB-ADV) and GATT bearer (PB-GATT), and the Mesh Proxy Service (Server).

Light LC Setup Server model

The Light LC Server model collects the data from occupancy and ambient sensors. When the light controller is enabled (see LIGHT_LC_DEFAULT_MODE), this model controls the lightness output. The Light Lightness Setup Server model is used to reflect the changes in the lightness output on the lightness level of lights through the binding between the Light LC Linear Output and Light Lightness Linear states of these two models.

The Light Lightness Setup Server model can be still controlled with the Light Lightness Client. However, the light controller is switched off automatically by the Light LC Server as soon any mesh message to change the lightness value is received (for example, the Light Lightness Set or any other message that can change the bound lightness state value). Use a Light LC Client model to turn the light controller on again.

Note
This example does not provide the Light LC Client model example.

For more information about the Light Lightness Setup Server model, see the light lightness example.

The Light LC Setup Server supports BLE Mesh Occupancy and Ambient Lux Level sensors – whose values are received through the Sensor Status messages. Sensors use the Sensor Server model to publish Sensor Status messages.

The Light LC Setup Server model uses the Proportional Integral (PI) Feedback Regulator to control the lightness output. The PI Feedback Regulator reads the ambient light sensors' data at regular intervals.

For more information about the Light LC models, see Light LC models documentation.


Hardware requirements

You need at least three compatible development kits for this example:

Additionally, you need one of the following for provisioning:

See Compatibility for information about the compatible development kits.

Note
This example uses the PWM peripheral to control the brightness of the LED.

Software requirements

To test this example, you need to use the following additional software:

Note
The Sensor server example implements an emulated Motion Detect sensor. It does not implement an ambient light sensor.

Setup

You can find the source code of this example in the following folder: <InstallFolder>/examples/light_lc/server

LED and button assignments

The following LED and button assignments are defined for this example:


Testing the example

To test the light LC server example, first build this example, the light switch client example, and the sensor server example by following the instructions in Building the mesh stack.

Note
The Mesh Model Specification mentions that the default value of the mode of the light controller to be set to (0x0). This means that the light controller is turned off by default. To enable the light controller, the Light LC Client model is used. However, this example does not provide the Light LC Client example. For this reason, in this example the light controller is switched on by default. This has been done by changing the default value of the LIGHT_LC_DEFAULT_MODE in nrf_mesh_config_app.h to (0x1).

After building is complete, use one of the following methods, depending on the preferred provisioning approach:

Evaluating using the static provisioner

See provisioner example testing section for detailed steps required to provision and configure the boards using the static provisioner.

Evaluating using the nRF Mesh mobile app

See Evaluating examples using the nRF Mesh mobile application for detailed steps required to provision and configure the boards using the nRF Mesh mobile app.

The following naming convention is used in the app:

The following model instances must be configured in the app for this example:

When setting publication with nRF Mesh mobile app:

Once the provisioning is complete, you can start Interacting with the boards.

Interacting with the boards

Once the Light LC server board is started after provisioning, the light controller will be turned on. The example starts in the Standby state, and the LED 1 is driven to the lowest light level (either determined by the LIGHT_LC_SERVER_LIGHTNESS_STANDBY_PID propety or a higher level, because of the light feedback from the ambient light sensor that attempts to keep the light at a minimum illuminance determined by the LIGHT_LC_SERVER_AMBIENT_LUXLEVEL_STANDBY_PID property).

At this stage, you can interact with the Light LC server example by using the following options:

Issuing the Occupancy On event or the Light On event triggers the following chain of events, as shown on the Figure 6.4 of the Mesh Model Specification:

You can issue new events at any time. This includes pressing Button 2 (or 4) on the Light switch client board to send a Light Off event. In such case, the state machine will start transition depending on its current state machine state and will set the brightness of the LED 1 according to the lightness level defined for the current state.

Note
For the testing purposes, the default time values for the various states are very short (between 2 and 10 seconds). When the Light LC Setup Server is running in a production environment, these values can be set to minutes or hours. For more the information about the format, units and allowed values of the properties representing these values, see Section 4.1.3 of Mesh Device Properties, Mesh Device Properties XML and Mesh Characteristics XML.

Lightness, illuminance, and transition time properties

The properties' values are controlled through the Light LC Client model.

The minimum lightness value at any state is determined by the following properties:

The illuminance value at any state is determined by the following properties:

If the values for these properties are not being detected by the PI Feedback Regulator, it will attempt to drive the LED 1 to a higher brightness.

If there were no reports from an ambient light sensor, the PI Feedback Regulator will not attempt to drive the LED 1, and the LED 1 will be driven by the state machine to the lightness values defined by the properties values specified for each state.

The factory default values of the lightness and illuminance properties are controlled through the corresponding defines:

The transition time is determined by the following properties:

You can make the state machine to transition instantly between the Standby and Run states. To do that, use RTT command 1 to toggle the properties of the state machine. After setting the corresponding properties to 0 you should notice the immediate transition between these states, when Occupancy On or Light On event is reported.

The factory default values of the time properties are controlled through the corresponding defines:

If you want to edit the factory default values, do this in nrf_mesh_config_app.h of the Light LC server example. Follow instructions in Testing the example to re-build and re-provision the example.

Delaying occupancy report transition

By default, when occupancy has been reported by the Sensor Server model through Sensor Status messages, the transition will start immediately. You can postpone the transition by setting a delay time in LIGHT_LC_DEFAULT_PR_TIME_OCCUPANCY_DELAY_MS in nrf_mesh_config_app.h of the LC server example.


Documentation feedback | Developer Zone | Subscribe | Updated