mozilla / connected-devices-experiments

INACTIVE - http://mzl.la/ghe-archive - A place to publish experiments and investigations from the Connected Devices team
10 stars 6 forks source link

Zigbee, Z-Wave #23

Closed mikehenrty closed 2 months ago

mikehenrty commented 8 years ago

Let's create an experiment using both Zigbee and Z-wave protocols.

sfoster commented 8 years ago

Why isn't this 2 different issues - they are quite different in the sense that one is proprietary while the other open(ish)

mikehenrty commented 8 years ago

I think the goal is to understand the difference between the two approaches, so we want an experiment that can try to do something similar with both.

benfrancis commented 8 years ago

Experiment: Measure the temperature on the different floors of my house so I can re-balance my central heating system.

I plan to start with a Raspberry Pi, an XBee Zigbee adapter and some Zigbee temperature sensors.

Currently researching what hardware to buy.

benfrancis commented 8 years ago

Progress Report

XBee

I did some research into the XBee adapters from Digi. It turns out that not all of them use Zigbee and there are lots of different variants. Some are capable of point to point, some are point to multi-point and some are mesh (ZigBee). The Series 1 adapters only do P2P or P2M but the latest ZB modules (sometimes called Series 2) are capable of ZigBee mesh networking. They are more complicated to user than Series 1 as they require some configuration, but are more versatile.

The modules come in programmable and non-programmable variants, through-hole and surface mount variants, and various different antenna options. There are also "Pro" variants and there's the XStick which is a USB ZigBee network adapter (comes in mesh and non-mesh variants).

The through-hole and surface mount options all have the same pin-out (basically a standard serial connection, quite a few GPIO pins and built-in analogue to digital converters), through-hole is better for prototyping. The USB stick is useful if you just want to use a PC as a co-ordinator.

The XBee Pro options are slightly bigger and consume more power because they have a greater range, but not needed for most applications.

The on-chip antenna option is fine for most indoor applications, the wire antenna has a better range outdoors and there are also variants which allow you to attach your own antenna for more flexibility or range.

RaspBee

I also considered the RaspBee from Dresden Elektronik which is a ZigBee module for the Raspberry Pi which you can buy on Amazon, but the reviews suggest that documentation and support is lacking.

Temperature Sensors

My original plan was to buy pre-built ZigBee temperature sensors, but these are actually quite hard to come by. Digi (who make the XBees) also make a ZigBee environment sensor which has temperature, humidity and light sensors all in one package, but they cost about $99 each which isn't really suitable for my application.

The ZigBee Alliance has a database of ZigBee certified products and they list some temperature sensors (TS-9ZBS or RS-23ZBS with a built-in LCD screen) from a Taiwanese company called Climax Technology. They have European offices in Germany and France but don't list any prices on their web site. I enquired about prices but so far haven't heard back.

XBee ZigBee Mesh Kit

I decided to buy the XBee Zigbee Mesh Kit from Digi which is a development kit to get you started with ZigBee mesh networking, with online tutorials. It comes with three programmable XBee modules, three developer boards and three USB cables and the software needed to program them works on Windows, Mac and Linux. My plan is to start out with the tutorials to learn about ZigBee networking and how to program the XBees. It may then be possible to connect a generic temperature sensor directly to the ADC pins on the XBees.

I also bought an XStick USB adapter to act as a co-ordinator, either plugged into my PC or a Raspberry Pi.

benfrancis commented 8 years ago

21/3/2016

Received the XBee ZigBee Mesh Kit and XStick and started to work through the tutorials.

dsc00814

802.15.4 defines the physical (PHY) layer and Medium Access Control (MAC) layer to handle addressing and message transmission/reception. ZigBee defines the Network (NWK) layer to handle network structure, routing and security. ZigBee also defines an "Application Support Sub-layer" (APS) and "ZigBee Device Objects" (ZDO) to provide a framework of an application layer.

ZigBee defines three different device types:

Found various "Grove" temperature sensors which can be plugged directly into the XBee, but they are all out of stock (e.g. http://www.seeedstudio.com/depot/Grove-Temperature-Sensor-p-774.html or http://www.seeedstudio.com/depot/Grove-TemperatureHumidity-Sensor-HighAccuracy-Mini-p-1921.html)

Installed the XCTU software from Digi's website. Able to detect an XBee device connected to the Grove development board and view and set its properties.

detected

benfrancis commented 8 years ago

22/3/2016

Plugged the three XBee adapters into the Grove development boards and configured them to share the same network.

dsc00849

Configured one as a co-ordinator, one as a router and one as an end device which sleeps for 5 seconds and then is awake for 5 seconds. Successfully detected the router and end device wirelessly connected to the coordinator device. (Note: The end device is difficult to connect as it falls asleep, pressing the commissioning button keeps it awake for 30 seconds to help detect it.)

Successfully sent text messages from the router and end device to the co-ordinator wirelessly via the console in the XCTU software.

communication

\o/

benfrancis commented 8 years ago

24/03/2016

One of the Grove sensors (Temperature and Humidity Sensor) came back into stock at $11.50 but these sensors use an I2C interface. Although the Grove development board for the XBee has a port marked I2C it's not clear whether the XBee modules provided in the developer kit can read data over I2C directly. The documentation describes reading sensor data from both digital and analogue pins, but doesn't specify whether I2C can be used. A sales representative at Digi was not able to tell me and I haven't yet received a response from their tech support.

Instead I've managed to find some Grove analogue temperature sensors which can be plugged directly into the analogue pins of the XBee modules and were in stock at CPC (Farnell) for just ~£3 each, so I've ordered some.

These sensors just include a thermistor which can detect ambient temperature using a resistance value, so some calculation will be required to turn that into a temperature. The sensors have a range of -40 - 125ºC and an accuracy of ±1.5ºC which isn't great but probably sufficient for my purposes.

carlospalmae commented 8 years ago

Hello

I have a question

ca be programed the xbee grove development board? like arduino UNO for example.

thanks,

benfrancis commented 8 years ago

Digi Technical support advised me that in order to use I2C the programmable versions of the XBee modules would need to be used. It probably also requires writing custom code. The XBee modules which come with the ZigBee Mesh Kit I bought are not the programmable ones.

So yes, you can program the XBee modules but you have to get the right ones.

In the end I bought analogue temperature sensors which should work with the XBee modules I already have.

benfrancis commented 8 years ago

Previously I configured the XBee modules as a co-ordinator, router and end node as described in this exercise.

Now I've completed the first exercise I want to start to configure my ZigBee mesh network of temperature sensors as the first step in building a Web of Things system. I want to configure the XStick as the coordinator and the three XBees as routers so that they can form a self-healing mesh network. So far I have:

Then in network discovery mode in XCTU you can see the topology of the mesh network and how all the nodes are connected:

xbee-mesh

Side note: This time one of the XBees was powered up by a 1.5 amp phone battery booster which seems to work.

benfrancis commented 8 years ago

I've managed to configure one of the XBee routers to send temperature data from the Grove analogue temperature sensor over the ZigBee network to the XStick acting as a co-ordinator, plugged into a Raspberry Pi. By adapting the instructions here.

So in other words I've created a temperature sensor which can send data to a Raspberry Pi over a low-power wireless mesh network.

I can see the data coming in over the serial port /dev/ttyUSB0 on the Raspberry Pi but it's gobbledygook.

serial_temperature_data

I need to try to understand the serial format being used so I can try to create a WoT abstraction on top of it.

toby53 commented 7 years ago

Hi, Did you need to write any code to get this working ? I'm building moisture / temp / hudmidity sensor network. I kind of know what you are going through, I purchased the wireless dev kit with XBee SC2s. It came with the grove development boards and the XBees. I also got a digi X2 connect gateway, which I got connecting (still learning). The sensors need to be cheap and run on solar and was hoping the normal sensors could be a board, battery, solar panel and a moisture sensor vs a pi or arduino. However, I got a dexter grovepi working good on direct connect sensors.

benfrancis commented 7 years ago

@toby53 This was mostly using the XCTU tool but there were some steps that required running the demo Java code Digi provides. One the examples in the tutorials linked to the wrong source code but I informed them and I think they've fixed that now.