nRF5 SDK for Mesh v4.1.0
Light LC server example
This example is not supported by the nRF52810 SoC.

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.

For demonstration purposes, this example includes a prebuilt HEX file with the occupancy sensor example.

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 two supported development kits for this example:

Additionally, you need one development kit for the provisioner if you decide to use the static provisioner example. For details, see software requirements.

See Compatibility for the supported development kits.

Note
This example uses the PWM peripheral to control the brightness of the LED. For this reason, it cannot be run on the nRF51 devices.

Software requirements

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


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 and the light switch client example by following the instructions in Building the mesh stack.

Using 40+ servers with static provisioner
If you have more than 40 boards for the servers and decided to use the static provisioner example:
  1. Set MAX_PROVISIONEE_NUMBER (in example_network_config.h) to the number of boards available.
  2. Rebuild the provisioner example.
  3. Set MAX_AVAILABLE_SERVER_NODE_NUMBER in nrf_mesh_config_app.h of the client example to the value set for MAX_PROVISIONEE_NUMBER.
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

Complete the following steps:

  1. Flash the examples by following the instructions in Running examples, including:
    1. Erase the flash of your development boards and program the SoftDevice.
    2. Flash the provisioner and the client firmware on individual boards and the server firmwares on other boards.
  2. After the reset at the end of the flashing process, press Button 1 on the provisioner board to start the provisioning process:
    1. The provisioner provisions and configures the client and assigns the address 0x100 to the client node.
    2. The two instances of the Light Switch client models are instantiated on separate secondary elements. For this reason, they get consecutive addresses starting with 0x101.
    3. The provisioner also provisions and configures the servers at random. It assigns the Light LC servers consecutive addresses starting with 0x501, and adds them to odd and even groups. It assigns the Sensor servers consecutive addresses starting with 0x801, and adds them to odd and even groups.
      Note
      - The sequence of provisioned devices depends on the sequence of received unprovisioned beacons.
      - You can use RTT viewer to view the RTT output generated by the provisioner. The provisioner prints details about the provisioning and the configuration process in the RTT log.
  3. Observe that the LED 1 on the provisioner board is turned ON when provisioner is scanning and provisioning a device.
  4. Observe that the LED 2 on the provisioner board is turned ON when configuration procedure is in progress.
  5. Wait until LED 1 on the provisioner board remains lit steadily for a few seconds, which indicates that all available boards have been provisioned and configured.

If the provisioner encounters an error during the provisioning or configuration process for a certain node, you can reset the provisioner to restart this process for that node.

Evaluating using the nRF Mesh mobile app

See the information on the main Examples page 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