Table of Contents

ZIGBEE sensor

Motivation

In home automation ZIGBEE is an alternative to WiFi based communications and already well integrated in Home Assistant. Also due to the low-power and mesh capabilities you can find it in commercial products like TRADFRI from IKEA or HUE from Philips. In the DIY world it's not yet so well penetrated as Wifi (e.g. ESP8266 or ESP32 modules). But a quite easy and flexible solution I could find and use. Here the description…

By the way, the idea of this project was triggered by ZIGBEE pulse counter and WATERIUS

Planning

There are 3 types of ZigBee Devices:

  1. ZigBee Coordinator Device: It communicates with routers. This device is used for connecting the devices.
  2. ZigBee Router: It is used for passing the data between devices.
  3. ZigBee End Device: It is the device that is going to be controlled

In order to setup ZIGBEE you need at least one ZigBee coordinator device. In my case I use YELLOW from Home Assistant where a ZIGBEE module (Silicon Labs MGM210P Mighty Gecko) is on-board. In common use is also Zigbee2MQTT with a supported ZIGBEE adapter of your choice. I use this approach for debugging purpose only.

Modules

In order to build a DIY Zigbee device (End Device or Router) we need a programmable Zigbee module. Several modules can be found in the market but I stick to E18-MS1-PCB from Chengdu Ebyte Elec Tech. It's based on CC2530 from Texas Instruments a bit outdated but cheap and easy to get.

E18-MS1-PCB

Quirks & Co.

For DIY devices you may have to teach the coordinator software how to deal with your Zigbee data. In Home Assistant quirks bridge the functionality gap created when a DIY device deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devices.

A similar approach is given for Zigbee2MQTT by embedding a javascript based external device description.

Hardware

In order to cover a bunch of application I designed a standard PCB that allows to connect sensors and/or actuators via GPIO, I²C or UART. Most with level shifter to allow 5V and 3.3V interfaces.

Schematic

PCB

The final PCB is quite compact with a size of 44.5 x 24mm. On top you see the programming interface (J1) and a button (SW1). The yellow LED (LED1) is used as an indicator. A 5V power supply can be connected via 2-pin JST connector (J7) or Micro-USB. A 3.3V regulator is on-board too. The UART interface has 5V signal level and the I²C is standard 3.3V. The level of additional two GPIOs can be selected between 3.3V and 5V by jumper. All 4-pin XH connector (J3-J6) provide a power pin so that a sensor can directly be connected.

 Soldered PCB

Software

For long I hesitated to step to ZIGBEE as the firmware development could become a challenge. There are a lot of step-by-step descriptions public but it's look like not to be an out-of-the box task. But I could find a couple of projects utilising the PTVO firmware. The firmware tool allows creating a ZIGBEE device (has to be TI SOC based) with easily configurable functionality, including inputs, outputs, ADC, pulse counter/generator, I²C, external sensors.

After some tests I was impressed and convinced how easy it is to setup a ZIGBEE device. This tools not only outputs the binary file (.hex) that can be directly programmed to the ZIGBEE module, it also generates the custom files for your coordinator of choice (e.g. quirks for Home Assistant). No need to program a single line of code.

An 1st application setup is described here

Programming

In order to program the firmware into the ZIGBEE module we need a programming adapter like SmartRF04EB from Texas Instruments. In order to save money your can buy one of the Chinese copies from your online-shop of choice.

SmartRF04EB

Five pins from DEBUG interface (connector J1) have to be 1 by 1 connected to the programmer.

How to connect the programmer

The programming software SmartRF Flash Programmer can be downloaded from TI's website (need quick export control if outside US). The software is self explaining.

Programming ongoing...

1st Application Water Meter

We are not connected to government water pipe but use our own dwell pump in combination with a 2000 liter water tank. In order to measure the water consumption we need a water meter. An ideal challenge for the new ZIGBEE module.

YF-B1 Hall Effect Water Flow Meter/Sensor

This sensor sits in line with our 1/2“ water pipe and contains a pinwheel sensor to measure how much liquid has moved through it. There's an integrated magnetic hall effect sensor that outputs an electrical pulse with every revolution. The sensor signals can be directly connected to J3.

Complete sensor in 3D printed case

The setup of PTVO firmware is very easy. Just define P21 as counter and set the interval to 60 sec. Every pulse longer than 1ms at P21 will be counted.

PTVO setup

After pairing the PTVO firmware will send the counter value to the coordinator. In my case the sensor gives 360 pulses per litre. This calculation as well as the daily consumption can be easily done in Home Assistant. The following examples show the results:

Water Consumption in l/min Water consumption per day

This sensor is now installed since more than 2 month without any issues. Many thanks to PTVO for his great firmware tool .

Downloads

If you like my articles feel to donate a cappuccino or so…