IMPORTANT: You must be part of the Matter Private Beta Program to start developing Matter devices and apps in the Google Home Developer Console. Apply now

Nordic Semiconductor

nRF52840

This example functions as a light bulb device type, with on/off capabilities. The steps were verified on an nRF52840 development board.

This example uses a test Vendor ID (VID) and a Product ID (PID) of 0x8005.

Initial setup

  1. Install dependencies and tools: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_installing.html

    For MacOS users, make sure Python 3.8 is installed and is the default Python interpreter on your machine (Python 3.9 won't work).

  2. Install the nRF Command Line Tools: https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools

  3. Install the GNU toolchain: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/downloads

  4. Install the GN meta-build system: https://gn.googlesource.com/gn/. Make sure the gn binary is in your PATH.

  5. Create a file ~/.zephyrrc and add the following lines:

    export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
    export GNUARMEMB_TOOLCHAIN_PATH="<path_to_arm_gcc_folder>"
    Replace <path_to_arm_gcc_folder> with the path of your ARM GCC toolchain installation. For example, if you installed the ARM toolchain from a .pkg file on MacOS, it will be installed under the folder /Applications/ARM.

  6. Install West:

    pip3 install west
    If you already have west installed, make sure it's updated to the latest version:
    pip3 install -U west

  7. Install the nRF Connect SDK (NCS):

    cd ~
    mkdir ncs
    cd ncs
    west init -m https://github.com/nrfconnect/sdk-nrf --mr v1.7.1
    west update
    west zephyr-export

    1. Install additional requirements for NCS:
      pip3 install -r zephyr/scripts/requirements.txt
      pip3 install -r nrf/scripts/requirements.txt
      pip3 install -r bootloader/mcuboot/scripts/requirements.txt
      pip3 install pyelftools
    2. Export environment variables:
      source zephyr/zephyr-env.sh
    3. If you have a ~/.zephyrrc file (created in the previous step), it should be automatically imported too. If not, you may import it manually:
      source ~/.zephyrrc
    4. Check your environment with this command:
      env | grep -E "TOOLCHAIN|ZEPHYR"
      You should see output similar to:
      ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
      ZEPHYR_BASE=/home/janesmith/zephyr
      GNUARMEMB_TOOLCHAIN_PATH=/opt/gcc-arm-none-eabi-10.3-2021.10
      The value for ZEPHYR_TOOLCHAIN_VARIANT should be gnuarmemb. The value of ZEPHYR_BASE should be ${HOME}/zephyr. As mentioned in Step 5, GNUARMEMB_TOOLCHAIN_PATH should be set to the path of your ARM GCC toolchain installation, which may be different than the above example.
  8. Clone and initialize the connectedhomeip repo:

    cd ~
    git clone https://github.com/project-chip/connectedhomeip.git
    cd connectedhomeip
    git fetch origin interop_testing_te9
    git checkout FETCH_HEAD
    git submodule update --init --recursive
    source ./scripts/activate.sh

  9. Update the nRF Connect SDK to the most recent supported revision:

    python3 scripts/setup/nrfconnect/update_ncs.py --update
    cd examples/lighting-app/nrfconnect

Build the image and flash the board

  1. Build the image:
    west build -b nrf52840dk_nrf52840
  2. Connect the board to your computer, and flash the image:
    west flash --erase

Validate the example

  1. The device should present itself as a USB serial device on your computer. You may look it up in /dev/:
    ls -la /dev/tty*
    You can open the serial console with screen or minicom. For example, if the device is at /dev/ttyACM0:
    screen /dev/ttyACM0 115200
  2. If the board has been paired before, it's recommended that you factory reset it. Long press Button 1 for >5 seconds. The LEDs should blink 3 times.
  3. Turn on BLE advertisement manually (needed for the device to be discovered by GHA). Press Button 4 on the board, and you should see a message like this in serial console:
    I: [DL] CHIPoBLE advertising started
  4. To toggle the lightbulb's state (on/off), click button Button 2. It should toggle LED2.

Next steps

When your Matter example has been successfully built, create a developer project.