Reader small image

You're reading from  BeagleBone Home Automation Blueprints

Product typeBook
Published inFeb 2016
Publisher
ISBN-139781783986026
Edition1st Edition
Right arrow
Author (1)
Rodolfo Giometti
Rodolfo Giometti
author image
Rodolfo Giometti

Rodolfo Giometti is an engineer, IT specialist, GNU/Linux expert and software libre evangelist. He is the author of the books BeagleBone Essentials, BeagleBone Home Automation Blueprints and GNU/Linux Rapid Embedded Programming by Packt Publishing and maintainer of the LinuxPPS projects. He still actively contributes to the Linux source code with several patches and new device drivers for industrial applications devices. During his 20+ years of experience, he has worked on the x86, ARM, MIPS, and PowerPC-based platforms. Now, he is the co-chief at HCE Engineering S.r.l., where he designs new hardware and software systems for the quick prototyping in industry environment, control automation, and remote monitoring.
Read more about Rodolfo Giometti

Right arrow

Chapter 11. A Wireless Home Controller with Z-Wave

In this project, we'll see how to implement a little wireless home controller by using a Z-Wave controller connected with our BeagleBone Black and two Z-Wave devices: a wall plug and a multisensor device. With the former, we'll be able to turn on and off every household appliance connected to it, and, at the same time, measure its power consumption. With the latter, we'll be able to measure several environment variables like temperature, humidity, and luminance (and have a motion detector capability too).

The Z-Wave communication protocol allows us to manage several home automation sensors and actuators wirelessly, so we don't need to modify our pre-existing plant. Also, we can easily add a power consumption measuring system or several environment sensors with a minor impact on the actual home layout.

As a last step, to keep the code simple, but in order to allow the user to easily manage the system, we'll write a simple web interface written...

The basics of functioning


This time, the project is a bit more complex than before, but all the complexity is not in the hardware (the connections are very simple, just plug in a USB dongle and the trick is done!,) but in the software! In fact, the management software to set up and control these devices needs some skills. Also, due to the fact that the Z-Wave world is really huge, and the lack of space for it in this book (I suppose I can ask my editor to write a dedicated book just to explain how to use the Z-Wave for the home automation projects!), I'm just going to present the very basics of the Z-Wave protocol, showing a minimal application that you can expand on your own.

As stated before, we're going to use a Z-Wave controller connected to the BeagleBone Black's USB host port to manage two Z-Wave devices: one used to measure some environment data, and one to turn on and off a connected device. So, what we have to do is to write some software to be able to send and receive messages to...

Setting up the hardware


The Z-Wave technology, which is oriented to the residential control and automation market, is designed to be suitable for battery-operated devices. In fact, one of its main goals is to minimize the power consumption. Despite this fact, it provides reliable and low-latency transmission of small data packets at data rates of up to 100 kbps, and a simple yet reliable method to wirelessly manage sensors and control lights and appliances in a house.

Note

For more information on Z-Wave, a good starting point is at https://en.wikipedia.org/wiki/Z-Wave.

In our project, we're going to use a Z-Wave controller on a USB dongle, one slave device powered by the same plug where it's connected to, and one multisensor device that can be powered by batteries or via an external USB connection.

Setting up the Z-Wave controller

The Z-Wave controller I used in this prototype is shown in the following image:

Note

The device can be purchased at the following link (or by surfing the Internet): http...

Setting up the software


As already stated, the more complex part of this prototype is the software. We need to install several software packages into our BeagleBone Black, and the software we have to write by ourselves needs some skills. However, don't worry, I'm going to explain all needed steps one at a time!

Setting up the Python bindings

Installing the Python bindings is quite complex since the software package named python-openzwave still seems in hard development, and it depends on tons of Python packages! However, I did it by getting a specific version of the project with the following command line:

root@beaglebone:~# wget http://bibi21000.no-ip.biz/python-openzwave/python-openzwave-0.3.0b5.tgz

Note

Other versions of the python-openzwave package are available at http://bibi21000.no-ip.biz/python-openzwave/.

Now, to explore the archive file, we can use the following command:

root@beaglebone:~# tar xvfz python-openzwave-0.3.0b5.tgz

A new directory, python-openzwave-0.3.0b5, is now created...

The final test


Now, to test the prototype, I connected the wall plug with my printer (the power load) and powered the multi-sensor with a USB port of my PC (just to avoid using the batteries). Then, I started the zwmanager.py program as follows:

root@beaglebone:~# ./zwmanager.py -d -l /dev/ttyACM0
zwmanager.py[2732]: callbacks installed
zwmanager.py[2732]: Starting...
zwmanager.py[2732]: network is started: homeid e4056d54
zwmanager.py[2732]: use openzwave library   = 1.3.482
zwmanager.py[2732]: use python library      = 0.3.0b5
zwmanager.py[2732]: use ZWave library       = Static Controller version Z-Wave 3.79
zwmanager.py[2732]: network home id         = 0xe4056d54
zwmanager.py[2732]: controller node id      = 1
zwmanager.py[2732]: controller node version = 4
zwmanager.py[2732]: network is now ready
zwmanager.py[2732]: detecting the switch node...
zwmanager.py[2732]:  - device Switch(9) is off
zwmanager.py[2732]: Press CTRL+C to stop
zwmanager.py[2732]: Started HTTP server on port 8080...

Summary


In this chapter, we discovered how to implement a basic home management system with a web interface that controls two Z-Wave devices to monitor some environment data and control a wall plug.

The presented code, even if a bit complex, can be easily extended to support more Z-Wave devices to manage a really complex network.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
BeagleBone Home Automation Blueprints
Published in: Feb 2016Publisher: ISBN-13: 9781783986026
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Rodolfo Giometti

Rodolfo Giometti is an engineer, IT specialist, GNU/Linux expert and software libre evangelist. He is the author of the books BeagleBone Essentials, BeagleBone Home Automation Blueprints and GNU/Linux Rapid Embedded Programming by Packt Publishing and maintainer of the LinuxPPS projects. He still actively contributes to the Linux source code with several patches and new device drivers for industrial applications devices. During his 20+ years of experience, he has worked on the x86, ARM, MIPS, and PowerPC-based platforms. Now, he is the co-chief at HCE Engineering S.r.l., where he designs new hardware and software systems for the quick prototyping in industry environment, control automation, and remote monitoring.
Read more about Rodolfo Giometti