b-parasite-esp32/code/nrf-connect/samples/zigbee
Matthew Dawson 54b1c48638
Implement workaround for errata KRKNWK-12017
Nordic has published an errata for the nRF Connect SDK for versions
>1.8.0 where a Zigbee End Device can end up getting stuck if the
parent device does not acknowledge the "Device Announcement packet".

They have a suggested workaround to implement in the SDK, which has
been adapted for the custom signal handler used here.

This is an effort to solve issues where my parasites would occasionally
drop off my network and require a reboot.  After 24Hrs, I've not yet
had a device disappear but it has taken >weeks before a device would
fail.  Unforunately it's hard to debug the board as the chips are in a
low power state when this occurs.
2023-05-10 10:45:30 -04:00
..
media/power-profile More accurate power profile 2022-12-10 15:48:02 +01:00
src Implement workaround for errata KRKNWK-12017 2023-05-10 10:45:30 -04:00
.gitignore Zigbee sample works with nRF52840dk + zigbee2mqtt 2022-12-07 20:10:51 +01:00
b-parasite.js Add illuminance cluster & reporting 2022-12-10 10:47:16 +01:00
CMakeLists.txt [zb] Implement double-reset factory resetting method 2022-12-27 19:22:01 +01:00
Kconfig [zb] Implement double-reset factory resetting method 2022-12-27 19:22:01 +01:00
prj.conf Update Zigbee example to work with SDK 2.2.0 2023-01-22 02:51:24 -05:00
prj_debug.conf Setup Kconfig for prstlib 2022-12-19 18:34:03 +01:00
README.md [zb] Implement double-reset factory resetting method 2022-12-27 19:22:01 +01:00
zigbee.code-workspace Links prstlib and restructures project to match other samples 2022-12-07 20:10:52 +01:00

Zigbee firmware sample

This sample is adapted from the zigbee_template from the nRF Connect SDK. It's a basic experimental/educational/exploratory firmware sample for b-parasite.

Clusters

These clusters are defined in the sample:

Cluster ID Name
0x0001 Power Configuration
0x0400 Illuminance Measurement
0x0402 Temperature Measurement
0x0405 Relative Humidity Measurement
0x0408 Soil Moisture Measurement

Pairing Mode

The sample will first boot and start looking for a Zigbee coordinator - in pairing mode. The onboard LED will be flashing once a second while in this mode. Once a suitable network is found, the LED will briefly flash 3 times and remain off.

Factory Reset

A factory reset will make b-parasite forget its network pairing information and switch to pairing mode. There are two (mutually exclusive) methods to perform a factory reset, controlled by the CONFIG_PRST_ZB_FACTORY_RESET_METHOD config flag.

Factory Reset Method 1 (default) - Double reset

Resetting b-parasite twice in the timestamp of 5 seconds will perform a factory reset. With this method, both shorting the RST pin to ground and removing-inserting the battery counts as a reset.

For better results, wait > 1 and < 5 seconds second between the resets. The LED will flash a total of 8 times to indicate it worked.

Factory Reset Method 2 - Reset Pin

In this method, there's a distinction between two reset modes.

Power up mode

The device enters this mode when it is powered. For example, swapping an old battery or connecting to eternal power. This is the "usual" reset mode, and joined networks will be remembered.

Reset pin mode

If the device's RESET pin is briefly grounded, the device will effectively be factory reset. The device will leave its previous network and start looking for a new one.

While it works, this method can be finicky - an accidental pin reset will perform an unwanted factory reset.

Configs

Available options in Kconfig. Notable options:

  • CONFIG_PRST_ZB_SLEEP_DURATION_SEC: amount of time (in seconds) the device sleeps between reading all sensors and updating its clusters
  • CONFIG_PRST_ZB_PARENT_POLL_INTERVAL_SEC: amount of time (in seconds) the device waits between polling its parent for data

Home Assistant Integration

This firmware sample has only been tested with Home Assistant, using one of the following integrations.

Zigbee Home Automation (ZHA)

With the ZHA Home Assistant integration, b-parasite should work out of the box.

Zigbee2MQTT & Home Assistant

With Zigbee2MQTT, a custom converter is required. The b-parasite.js file contains such a converter. See Support new devices for instructions.

Battery Life

While sleeping, the device consumes around 2 uA: sleeping current In the active cycle, it averages around 125 uA for 1 second: active current