Skip to content

Building and Running the Mesh examples

This section describes how to build the mesh library and example applications with CMake, and the run my light switch example.

Before you start building, remember to set up the mesh development environment first. See Setting Up the Mesh SDK for details.

Generating build files

Good practice is to create a build folder in the grove-mesh-kit directory, where all artifacts generated by the Ninja build system are stored:

Open terminal and change directory to:

cd ./grove-mesh-kit

Creat a build folder and change directory to it:

mkdir build && cd build
Before you can build with Ninja, you must generate the correct build files with CMake.

cmake -G Ninja -DTOOLCHAIN=gccarmemb -DPLATFORM=nrf52840_xxAA -DBOARD=nrf52840_mdk -DFLASHER=pyocd ../nrf_sdks/nRF5-SDK-for-Mesh/

Building the stack and examples

After the Ninja build files are generated, running ninja <target> to build the targets. Here we take the target my_light_switch_client as an example:

ninja my_light_switch_client_nrf52840_xxAA_s140_6.1.0

Other targets are ready for building. For example:

ninja my_light_switch_server_nrf52840_xxAA_s140_6.1.0
ninja my_light_switch_provisioner_nrf52840_xxAA_s140_6.1.0

Running the example

To run examples on your nRF52840-MDK, first connect it to your computer with a USB cable. When your board is detected, run ninja flash_<your target> to flash the example:

ninja flash_my_light_switch_client_nrf52840_xxAA_s140_6.1.0

Run a terminal application like PuTTY or screen to print the log information:

screen /dev/cu.usbmodem141102 115200

Flash other nRF52840-MDK boards with Server target:

ninja flash_my_light_switch_server_nrf52840_xxAA_s140_6.1.0

You can use the nRF Mesh mobile app to provision the client and server devices:

Next Steps

Congratulations! You may find your way around to build and run the mesh examples. And further more, you can create your own targets.

Create an Issue

Interested in contributing to this project? Want to report a bug? Feel free to click here: