Extending your Home Automation network with Raspberry Pi

Tags: Home Automation, Raspberry PI, Sensors

 

Just thought I would share that last night I decided to throw some code together which will mash up the Raspberry Pi along with the zVirtualScenes server

In reality you could deploy the scripts to any machine capable of running python (OSX, Windows, *nix, etc..).  All communication is done via UDP using Multicast groups, so every node on the network will send to this single group, and all other nodes will receive the events.

Interesting idea.

 

Here are some screen grabs from zVirtualScenes connected to a Raspberry Pi, with a PIR motion sensor:

1. Enabling the “SensorNet” adapter

ActivateAdapter

 

2. Auto-discovery working.  The server sends a “RegisterRequest” message to the group, and each node starts to report in with their capabilities.

DeviceAutoDiscovery

 

3. All motion values are stored in zVirtualScenes server, and can be used for triggering events

RaspberryPi with zVirtualScenes

 

4. Triggering an event based on motion detected on the RPI:

TriggerBasedonRpiMotionDetection

 

 

The idea here is that you can use the Raspberry Pi (base cost of $35) to setup a sensor network, a command network, etc.. on your LAN for all of your Home Automation needs.

 

Some examples


Have your garage door wired with a Pi and a Solid State Relay Switch (http://dx.com/p/ssr-10da-solid-state-relay-white-silver-230994), and have that device/switch show up in zVirtualScenes and also to be able to easy control it.

 

sku_230994_1[1]

 


You could setup a series of cheap Sensors in your home wired to a single or many Pi's, and have each readable/actionable in zVirtualScenes.  Some examples:

Triple-axis analog accelerometer - for measuring motion and tilt
Force sensitive resistor - for sensing pressure/force
Temperature sensor - for measuring from -40 to over +125 degrees C
10K breadboard potentiometer
Hall effect sensor - for sensing a magnet
Piezo - can be used as a buzzer or a knock sensor
Ball tilt sensor - for sensing orientation
Photo cell sensor - for sensing light
IR sensor - for sensing infrared light pulsing at 38KHz
IR LED - for use with the IR sensor

FYI, you can by ALL of those sensors, for $35 right now: http://www.adafruit.com/products/176

 

basicsensors_LRG[1]


Have XBMC announce what’s playing information, and to be able to control XBMC via zVirtualScenes



Monitor and control remote OSX, Windows, Linux desktops via zVirtualScenes
   Disk SMART status, watch dog for apps & services, etc.. and trigger events in your Home Automation network based on these events.



Have a different device in your network Monitor zVirtualScenes events and respond accordingly.  This really allows us to break out of just controlling z-wave enabled devices, to being able to control ANY device on your network. 


There is really no limit of the possibilities here.

 

Show me the code!

Right now it is a bit too early to share all of my code. I do plan on opening it all up under some no-limit license, once it gets to an acceptable point for publishing.

With that said, here is the gist of getting a PIR Motion sensor on a PI on the network - it is in python, so tread lightly... :)




import GPIO 
from App import App

app = App("RPI-Upstairs");  ##give this device a unique name on your network

##Import your sensors 
from sensors.zMotionSensor import zMotionSensor as MotionSensor

##register your sensors 
pin7pir = MotionSensor("Main Entry Motion Sensor (PIR)", #unique display name for this sensor on this device 
    7,              ## GPIO port used 
    GPIO,  app )     ##just ignore these, we are injecting our dependencies


pin7pir.monitor()  #setup this sensor to start monitoring for input


app.wait()  ## setup our wait loop for our daemon, to allow for the magic to happen


 

On the zVirtualScenes side of things, all you need to do is enable the "SensorNet" adapter, and all will be recognized and registered automatically. 

ActivateAdapter


 

How can I get my own Pi?


Sample shopping cart items to get a basic PI with a motion sensor.

 

998_LRG[1]
Raspberry Pi Model B 512MB RAM - $39.95
http://www.adafruit.com/products/998

 

 

pirsensor_LRG[1]

PIR Motion Sensor - $9.95
http://www.adafruit.com/products/189

 

 

ID501_LRG[1]

***5V 1A (1000mA) USB port power supply - $5.95
http://www.adafruit.com/products/501

 

 

microusbcable_LRG[1]

***USB cable - A/MicroB - 3ft - $3.95
http://www.adafruit.com/products/592

 

SD102_MED[1]

***4GB SD Card - $7.95
http://www.adafruit.com/products/102

 

Most of these items you should be able to get locally or even cheaper from any vendor, ebay, monoprice, amazon, etc..  On adafruit check out the “Distributors” tab, for local options.

Total cost so far, from adafruit.com, is about $68, which is cheaper than any z-wave enabled Motion detector on the market today!


Once the base costs are covered for the Pi, you can add a bunch of cheap, additional sensors to this device (and thus your network).

More to come.

No Comments