nRF5 SDK for Mesh v2.2.0
Dimming examples (experimental)

This demo project consists of two examples: the dimming server and the dimming client. In addition, it requires the provisioner example that is provided as part of the light_switch examples.

Hardware requirements

See the compatiblity section for information about the supported boards.

Note: This example uses the PWM peripheral for dimming. Therefore, it cannot be run on nRF51 devices.

Running the demo

To build the examples, follow the instructions in Building the Mesh Stack. Refer to the How to run examples section in Examples README for the commands required to program a device using nrfjprog.

  1. Erase the device flash of your development board and program the SoftDevice.
  2. Flash the provisioner firmware on one board, the client firmware on another board, and the server firmware on the remaining boards.
  3. After a reset, press Button 1 on the provisioner to start the provisioning and configuration of the devices. The provisioner first provisions and configures the client and then moves on to provision and configure the servers, one by one.
  4. Use the 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. While the provisioner is scanning and provisioning a device, LED 1 on the provisioner board is turned ON. During configuration, LED 2 on the provisioner board is turned ON.

The provisioner configures the two client model instances on the client board to communicate with the Odd and Even server groups.

Connect the RTT viewer to the dimming client to control the dimming level. Three message types are demonstrated: Set, Delta Set, and Move Set. The RTT input is used to emulate the button numbers 0 to 6, so to send level messages, you send numbers from 0 to 6 via the RTT viewer.

The client example is configured as follows:

Note: If you use the buttons on the DK instead of RTT input, you can only send Set and Delta Set messages. You cannot send Move message or switch between Odd or Even groups.

When provisioning and configuration of the client node and at least one of the server nodes is completed, you can send numbers using the RTT viewer and see the dimming action on LED 1 of the server boards.

You can also connect the RTT viewer to one of the servers and send 0 or 1 to locally increase or decrease the brightness of their LED 1 in steps. Observe the corresponding status printed in the RTT log of the client board.

Note: You cannot use buttons on the server boards since dimming server does not use simple_hal module.

If any of the devices are powered off and back on, they remember their configuration in flash and rejoin the network. More information about the flash manager can be found in the flash manager documentation.

If the provisioner encounters an error during the provisioning or configuration process for one of the nodes, you can reset the provisioner to restart the process for that node.

Provisioning with the nRF Mesh app

Instead of using a provisioner board, you can also use the nRF Mesh app:

  1. Switch off the provisioner board, and flash the client and server firmwares again.
  2. Download the nRF Mesh app for your mobile phone (iOS or Android) and provision the nodes.
  3. Bind the Generic Level client and server model instances on the nodes with the same app key.
  4. Set the publish address of the 1st Generic Level client model instance on the client example to the unicast address of any server node.
  5. Use the RTT viewer as described above to send level messages. Observe LED 1 on the corresponding server.

Details

The demonstration consists of two example applications that use the Generic Level Client/Server model.

Dimming client

The dimming client has a provisionee role in the network. The client accepts RTT inputs from 0 to 6 to control the state of LED 1 on the servers. It instantiates two instances of the Generic Level Client model. The provisioner configures this client model instances to communicate with the servers.

Dimming server

The dimming server has a provisionee role in the network. It instantiates one instance of the Generic Level server model to control the state of LED 1. It uses the APP_PWM library of the nRF5 SDK to control the brightness of the LED. The provisioner configures this server model instance to communicate with the client model on the client board and to publish a message when the value of the Level state changes.

The examples are based on the Generic Level model, which works with signed 16-bit level values. Therefore, the dimming server maps this range on the allowed range of PWM tick values. As a consequence, sending a level model message that sets the target level to zero results in a 50% duty cycle on the PWM output when the target level is reached.

Generic Level Client/Server model

The Generic Level Client/Server is used for manipulating the Level state. Note that when the server has a publish address set (as in this example), the server publishes information about any state changes to its publish address.

More information about the Generic Level model can be found in the Generic Level model documentation and the Generic Level server behaviour documentation.


Documentation feedback | Developer Zone | Subscribe | Updated