Starting with Z-Wave and dot net

Posted April 16 2011, tagged z-wave,

This is a basic introduction in building a dot net client on top of Open Z-Wave.  I'll walk through the process from setting up a network through to the basics of writing a client in c# or vb.net.

I've a few more posts on Z-Wave, so depending on what you're looking for, you might find them more relevant.

Introduction to Z-Wave

There are three key items needed to begin automating you home with Z-Wave.  These are

  1. Z-Wave controller (Aeon labs Z-Stick etc)
  2. Number of devices to control e.g. light switch, lamp dimmer
  3. Open Z-Wave

Once you have the hardware, you need to create the network.  The controller needs to be aware of each of the devices within the network and this is done (on the Z-Stick) by holding down the button until the LED starts to flash.  Hold the Z-stick near each device then turn on the device.  The LED should flash rapidlly to indicate the device has been registerd.

Once all devices have been added, then press the button on the Z-Stick again to take it out of discovery mode.

There are plenty of resources out there to help you with this. A quick search should get you going.

This video shows a demo of this application

Open Z-Wave

This is a library that takes care of all the low-level communication needed to control Z-Wave devices.  This is a walk through on using it to set up a simple console application that turns on all devices within the network.

First download the source for the libary from the following URL http://code.google.com/p/open-zwave/source/checkout.  On this machine, I've downloaded it to 
C:\Work\Z-Wave\

To build the library within Visual Studio, then open the solution within the following folder;
C:\Work\Z-Wave\dotnet\build\vs2010

Once the build is complete, first navigate to the following folder
C:\Work\Z-Wave\dotnet\examples\OZWForm
Within there should be a file called CopyFilesVS2010.cmd, running this will put the correct solution files in to the OZWForm directory.  This demo application can then be opened in Visual Studio and built. 

It is well worth while examining this application to see how everything fits together.  However if you want to start with the basics I've taken the basics out of it and written a very simple console application that turns on my lights.

Sample dot net Z-Wave application

The source for the application is available from: http://www.oliverjenkins.com/media/default/download/StartZWave.zip. If you've put the files from above in to a different location to me, then make sure that the configuration variables are set correctly. zWaveConfigPath is especially important to get right.

I had a problem with this application, until I added a trailing slash to the value.

Simply build and run the program.  It should fire up and tell you everything which you need to turn on a light using z-wave with dot net.

Don't worry if it takes a while to initialise.  I've waited a minute or so before for this process to complete.  Once the set up is complete the light / device is turned on by this line;

m_manager.SetNodeOn(m_homeId, node.ID);

Another warning is that on occation the network seems to never initialise.  If thats the case, then just re-start the program again.

Hope this is of use, let me know how you get on.

comments powered by Disqus