Zigbee sensor instructions

Posted on
Sat Feb 15, 2020 3:24 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Zigbee sensor instructions

I have been looking for an easy to use, cheap temperature sensor that most importantly has high WAF, and in doing so I came across the Aqara range from Xiaomi. Temperature, humidity and pressure in a small 2cm (1") square battery device all for $10! Seemed too good to be true. Only problem was they are zigbee and wont connect to the Hue hub, and wont work with the excellent Hue plugin we have.

https://www.aqara.com/us/temperature_humidity_sensor.html

Image

They are good value on both US and UK amazon but a little cheaper from Ali or Banggood. Both of those offer the full range of Temperature sensors, vibration / tilt sensors, water sensors, and battery wireless wall switches and hand held buttons.

However thanks to recent progress in both use of Node-Red connectivity to Indigo as well as Joe's amazing MQTT plugin there were some good alternatives.

I found a great little program that can run on a pi using a $10 USB stick , act as a zigbee hub and convert to MQTT that either Node-Red Indigo or MQTT Shims can pick up.

https://github.com/Koenkk/zigbee2mqtt

All this for the cost of the sensor and a £3-10 USB stick. The USB stick you need is CC2351. Shipped from China these can be had for as little as $3 but for one with an antenna and shipped lcoally they are more like £10. Also worth mentioning, that these sticks can be used as boosters, so if you have a few Pis around the house for pibeacon then you can build full house coverage quickly as these sensors wont act as a mesh as only battery, and neither will your Hue bulbs. Alternatively there is a variant of this board that can be mains powered standalone that can run as a standalone booster too.

You can buy dedicated cables to flash the required firmware onto the USB stick but this is not required.

If you have a Pi, you can plug it into the Pi and using 4 female-female jumpers you can connect it direct to the Pi GPIO to flash. The only problem is that the jumper cables dont fit unless you bend the pins on the USB stick out. They are soft and easy to bend and didnt feel like they would snap, but you will need to hold the cables in place with one hand whilst you enter the command on the Pi to flash. ITs only 3 minutes so doable.
https://www.zigbee2mqtt.io/information/alternative_flashing_methods.html

Full instructions are on the above site. Once you have flashed the USB stick, and installed the software to the Pi (or using the Linux instructions direct to your Mac) the easiest way to get started is actually to install the Node-Red admin panel.
Assuming you have Node-Red installed (which can also run on your Mac) then open up a new tab in node-red. Then click the hamburger icon and Import. Copy the contents of the flow file as text from here (double click on contents to select all), https://github.com/ben423423n32j14e/zigbee2mqttadminpanel and paste into the Import tab.

Screenshot 2020-02-15 at 22.27.13.png
Screenshot 2020-02-15 at 22.27.13.png (223.65 KiB) Viewed 4683 times


You will need to click into each of the 8 nodes in this flow, click edit Sub Flow, and change the MQTT server in the relevant nodes in each sub flow. You only need to do this the once.
Then Deploy and go to node-red_IP:1880/ui .

There change Permit Join to Allow and you are all good to go with pairing your device. On the Aqara temperature sensor it is just a quick press of the top button and a few seconds later it should show up. Much simpler than a zwave setup.
Screenshot 2020-02-15 at 22.26.47.png
Screenshot 2020-02-15 at 22.26.47.png (196.07 KiB) Viewed 4683 times


You can then rename the device. The device name will be the MQTT topic after zigbee2mqtt. You can use / in the name.

You can do pair devices from the command line, but I found it easier with the admin panel as I already run Node-Red for Alexa.

You can either then use Node-Red to receive the MQTT message and the Indigo palette to put the values into an Indigo variable or for a more complete integration, , you can then go to Indigo and MQTT plugin.
Last edited by siclark on Sat Feb 15, 2020 5:03 pm, edited 4 times in total.

Posted on
Sat Feb 15, 2020 3:29 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Zigbee sensor instructions

This is the output of the setup. Indigo devices reporting temperature, pressure and humidity, but each reporting all the states, and also showing battery power.
Attachments
Screenshot 2020-02-15 at 22.42.40.png
Screenshot 2020-02-15 at 22.42.40.png (238.14 KiB) Viewed 4669 times
Last edited by siclark on Sat Feb 15, 2020 5:00 pm, edited 1 time in total.

Posted on
Sat Feb 15, 2020 4:54 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Zigbee sensor instructions

The zigbee2mqtt program adds zigbee2mqtt to the start of the topic, and I added Aqara/{device name} to mine, so the attached is the sensor for my master bedroom. Its a simple non nested json structure.
Screenshot 2020-02-15 at 22.37.59.png
MQTT message
Screenshot 2020-02-15 at 22.37.59.png (222.82 KiB) Viewed 4671 times



Firstly you need to install the MQTT and MQTT Shims plugins by FlyingDiver / Joe if you havent already.

Then create a MQTT Broker device per the below screenshot.
Screenshot 2020-02-15 at 22.40.11.png
MQTT broker device
Screenshot 2020-02-15 at 22.40.11.png (97.36 KiB) Viewed 4676 times


You then need a Trigger setup again as per the screenshot. If you dont have the End: option, you need to upgrade to the latest version / beta. See the Shims forum thread for details.
Screenshot 2020-02-15 at 22.40.42.png
MQTT trigger device
Screenshot 2020-02-15 at 22.40.42.png (128.91 KiB) Viewed 4676 times


Finally you need to then setup a Shims device, again as per the screenshot. If you followed my naming convention, the unique ID, ie master bedroom is in the 3rd location, so enter 2.

Screenshot 2020-02-15 at 22.42.59.png
Shims device
Screenshot 2020-02-15 at 22.42.59.png (280.84 KiB) Viewed 4676 times


In mult-states key if you enter a '.' you then get all the states appearing in for the device. I created multple Indigo devices per sensor, but you could just have one and use the extra device states. Finally tick yes to reports battery and enter 'battery' as the payload key.

That should be it. You should then have your devices responding. The sensor only seems to report on change, so it can be a few minutes with no change. I found the quickest way to test was to breathe on it. The humidity should spike within a couple of seconds (it is that fast) then slowly drop back down, reporting changes all the time.

Hopefully the pictures to a better job than my words. Ask if any questions. I have the vibration device coming in a few days to test which should be similar setup. I then have the smart button/micro switch on order as well . I think I will use Node-Red to Indigo device connection for that one, having Node-Red trigger dummy devices in Indigo directly when pressed, rather than using Shims, but I;ll have a play and see what works best.

Finally I will get another USB stick ordered and test out the setting up a zigbee router, to expand the range.

Any questions, please ask. I'm excited to see what these devices, both the sensors and the control switches can do.

Posted on
Sun Feb 16, 2020 4:26 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Zigbee sensor instructions

Got my second cc2351 stick today. I'll be playing with setting that up as a booster tomorrow. Instructions will follow.

Posted on
Mon Feb 17, 2020 5:41 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Zigbee sensor instructions

Hi Simon,
siclark wrote:
Got my second cc2351 stick today. I'll be playing with setting that up as a booster tomorrow. Instructions will follow.

I have just ordered the Indigo coloured filament for my 3D Printer - hopefully it will be here by the end of the week. :)

Are your cc2351 sticks with or without antenna?

Posted on
Mon Feb 17, 2020 6:12 am
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Zigbee sensor instructions


One with, one without to test the difference so would be happy with either. Haven't decided on final locations yet.

Posted on
Mon Feb 17, 2020 6:14 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Zigbee sensor instructions

I found this post on Reddit: CC2531 with Zigbee2mqtt on MacOS, possible?

It appears the answer is YES according to a reply from Koenkk (the author of Zigbee2mqtt). :)

Now just need to work out how to do it. :wink:

Posted on
Mon Feb 17, 2020 8:13 am
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Zigbee sensor instructions

The answer to your unasked question?

Yes I do say above that you can use the Linux instructions to install direct to the mac. I didn't as I don't have room with the zwave stick there on the new Mac mini without buying a hub.

Posted on
Mon Feb 17, 2020 8:52 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Zigbee sensor instructions

siclark wrote:
... Yes I do say above that you can use the Linux instructions to install direct to the mac. ...

Missed that :oops:

I will give it a try when my CC2531 turns up. :)

Posted on
Mon Feb 17, 2020 11:25 am
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Zigbee sensor instructions

I wrote the instructions in one go so I'm sure they could be clearer.

Posted on
Mon Feb 17, 2020 3:48 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Zigbee sensor instructions

autolog wrote:
siclark wrote:
... Yes I do say above that you can use the Linux instructions to install direct to the mac. ...

Missed that :oops:

I will give it a try when my CC2531 turns up. :)

Did you get one with an aerial? Can't say I'm impressed with the signal on the one without.

Posted on
Tue Feb 18, 2020 1:49 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Zigbee sensor instructions

siclark wrote:
Did you get one with an aerial? Can't say I'm impressed with the signal on the one without.

Yes - I ordered one with an aerial. :)

Posted on
Tue Feb 18, 2020 12:02 pm
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Zigbee sensor instructions

CC2531 has turned up and is now connected to my Indigo iMac.

I have successfully installed zigbee2mqtt on the iMac.
Aqara Temperature/Humidity/Pressure sensor successfully paired and messages are being broadcast to my MQTT broker (mosquitto) running on the iMac.

I then use @FlyingDiver's MQTT Connector and MQTT Shims plugins. I have setup three Shim devices for Temperature, Pressure and Humidity.

All looks good so far. :)

This is quite an exciting development as it obviously opens up a much greater number of devices that can be potentially connected to Indigo.

Thanks to Simon (@siclark) for trail blazing this and for showing how it could be done and of course thanks to Joe (@flyingdiver) for the amazing MQTT plugins. :)

Posted on
Tue Feb 18, 2020 12:18 pm
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

Re: Zigbee sensor instructions

Great documentation, thank you!

I’m sure this is in there, but I’m a little uncertain: do i need nodejs/ nodered running in order to interface?

Posted on
Tue Feb 18, 2020 12:24 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Zigbee sensor instructions

You need nodejs and npm running on the machine which has the ZigBee USB stick.
Nodered only needed as it gives a graphical admin screen but you can do admin via command line.

I'll add a summary of requirements shortly.

Who is online

Users browsing this forum: No registered users and 2 guests