I recently started setting up a home Zigbee network – partially to experiment but also to try and reduce the number of esp8266-based devices on my home network. esp8266s are great, but I’ve discovered that they’re noisy in that they seem to emit a lot of 2.4GHz interference (calibrating them helps though).
Tasmota on esp8266 lights also tends to generate a lot of traffic. It, of course, depends on how you’ve configured them: have you set them up in a UDP broadcast group or are they individually connecting to an MQTT broker? The broadcast option generates less traffic, but it’s far from ideal. I thought Zigbee might solve these problems, especially thanks to mesh routing and 2 MHz bandwidth. I was right, Zigbee rocks, and thanks to its fairly standardised protocol it isn’t necessary to install custom firmware on devices. Zigbee is offline/local by default.
On this note the IKEA Tradfri range of Zigbee devices is insanely good value for money. They work really well.
The major stumbling block for someone in South Africa using Zigbee is the lack of good quality coordinator devices and routers. This post doesn’t solve the lack of decent coordinator hardware but it does help with routers. IKEA’s Tradfri range of devices also help because they behave as routers.
Enter the Nordic nRF52840 (available from RFDesign in Cape Town [I’m not sponsored, promise]):
Gratuitous photos 😀
There are a couple of important things to note about these dongles that I didn’t realise when I ordered them:
- The device is largely locked down: it comes with a bootloader pre-installed, which is very restrictive about what can be flashed to the device. You essentially can’t replace the bootloader without a J-Link programmer and a special “needle” interconnect kit.
- The esp8266/esp32 system really spoils one: you install the Arduino IDE and board defs, or you install esptool and flash MicroPython – easy… but the Nordic dongles require the download of a large SDK. Documentation is comprehensive but dated and confusing.
- There are many different bootloaders available for the nRF52 series of chips and there are various ways of flashing these devices through said bootloaders. This is largely because *the* raw way of flashing an nRF52 device is using a J-Link programmer, but they seem to be expensive and proprietary. Compare this to an Espressif device, which just requires a TTL UART interface.
- It may be obvious: nRF52 is the family, nRF52840 is the chip and PCA10059 is the dongle.
I found nRF Connect to be the only thing that consistently works (as opposed to their CLI nrfutil).
To create a barebones router, I downloaded the nRF52 SDK. This all assume Ubuntu 20.04.
I also grabbed nRF Connect for Desktop.
You’ll also need to install the ARM GCC Toolchain. Don’t install the toolchain yet though as there are many versions and you’ll need the version specific to your nRF SDK.
Decompress the nRF SDK
nrfsdk/examples/zigbee/light_control/light_bulb/pca10059/mbr/armgcc and run
At this point you’ll get an error message, which will probably require that you install
build-essential (if you don’t already have it). It will also potentially prompt you for a specific version of the ARM GNU Toolchain, which you should now download from the link above and decompress into
/usr/local. In my case this was
sudo tar -xv -C /usr/local -f gcc-arm-none-eabi-7-2018-q2-update.tar.gz
At this point, you can run
make and everything should *just work*.
nrfsdk/examples/zigbee/light_control/light_bulb/pca10059/mbr/armgcc navigate to the newly created
_build directory and select the file
nrf52840_xxaa.hex. This file can be dragged into the “Programmer” app in nRF Connect for Desktop. Do that, click “Write” and it should write the app to your dongle. Subsequent flashes will require you to first hit the “RESET” switch on the dongle. This is the switch that faces the antenna on the board.
By default, the example app emulates a light bulb and only operates on channel 16. If you’re like me and you have your network on a different channel, you can change the channel in
#ifndef ZIGBEE_CHANNEL #define ZIGBEE_CHANNEL 11 #endif