nRF WiFi Provisioning via Web Bluetooth

Aug, 23 2023

Nordic has entered the WiFi game with their new nRF7002 chip. Combined with the nRF5340, you have a really powerful IoT building block.

Nordic provides an iOS and Android application to provision WiFi credentials on the device. But, I wanted more control. Let's provision this device using Web Bluetooth.

Configuring the nRF7002 Dev Kit

There's a good getting started guide on the Zephyr Project's website.

We'll mostly copy these steps. Simply flash the MQTT example hex file onto the dev kit using nRF Connect for desktop.

Nordic's BLE Provisioning Service

Your dev kit will now advertise a WiFi provisioning BLE service. You can read about the service here.

The service contains the following 3 characteristics:

WIFI_VERSION_CHAR = '14387801-130c-49e7-b877-2881c89cb258' WIFI_CTRL_POINT_CHAR = '14387802-130c-49e7-b877-2881c89cb258' WIFI_DATA_OUT_CHAR = '14387803-130c-49e7-b877-2881c89cb258'

The characteristics use protocol buffers to transfer data back and forth. This was a bit of a learning curve for me, but this post helped a lot. The defined protocol buffer format is found in Nordic's provisioning application repository. The same files are used in our React project with the protobufjs library.

Interacting with our nRF7002DK's Provisioning Service

All requests will go to the WIFI_CTRL_POINT_CHAR. Status information will be notified to the WIFI_CTRL_POINT_CHAR.

Upon connecting to the device, subscribe to both WIFI_DATA_OUT_CHAR and WIFI_CTRL_POINT_CHAR then start sending commands to the WIFI_CTRL_POINT_CHAR.

When a START_SCAN command is sent to the WIFI_CTRL_POINT_CHAR, the WIFI_DATA_OUT_CHAR with notify the discovered networks.

The basic flow is as follows:

  2. FORGET_CONFIG (optional)
  4. STOP_SCAN (when a WiFi network is chosen by the user)
  5. SET_CONFIG (wait a few seconds for the device to connect)

Below is a demo of the application in use:

You can find the source code for the project on Github or you can try out a live version of the tool here.

You can read more about Web Bluetooth with React here.