Home Automation System Weather/Environment Sensing


One of the best things you can do for your system is feed it data about temperature, humidity, rain, wind, and other elements of the enviroment in and around your house. Using this data, you can then have it turn on and off heating and cooling systems, activate fans, or sound alarms based on paramaters you set. Using a web interface, you can also check the temperature or humidity of your house from elsewhere. 

The Weather Station

The best way to hook up environmental sensors to your system is to buy a predesigned weather station. These usually include a whole host of sensors, including indoor/outdoor temperature and humidity, barometric pressure, wind speed and direction, and even rainfall sensors.
 Personal weather stations have been around for a while, so it’s pretty easy to get a cheap one. I use a Radio Shack WX200, which is ancient (its bundled software wasn’t Y2K compliant) but still works well. You can pick one up on Ebay for less than $100. You can also get newer ones from companies like Oregon Scientific. Most consist of a central box that connections through wires or radio waves to several outdoor sensors.In choosing a station for connection to an HA system, make sure you find one that has a serial or USB computer connection (the wx200 uses a serial cable). Mount the central box near to your home server, then connect the sensors to it.

The Software

Once you have your weather station up and running, get it interfaced with your computer. To do this, I recommend using Virtual Weather Station, a software program which works with many different models (for a complete list, go here) and costs about $100.

Once you have VWS running, follow their instructions to get data from your weather station. If you would prefer not to pay for VW, look around and see if you can find a free program that interfaces with your station of choice (for the Wx200, try SB Weather). You’ll need to play with the output later on to get data into Powerhome, but it might be worth the savings.

Getting Data Out of Virtual Weather Station

In order to get weather data into Powerhome, there are two steps. First, you need to get VWS to export data in a format that PW understands. To do this, open VWS, then go to Settings–>CSV Export.

 

Choosing the CSV Option in Virtual Weather Station

 

This will bring up a box with options for outputting data.

 

Choosing the CSV Option in Virtual Weather Station

 

Make sure that the option for exporting a .CSV file is selected. Next, click Browse and select a folder on your computer where you would like the Virtual Weather Station data file to go. Finally, select how often you would like the data to refresh–personally, I went with 5 seconds, but if you’re not concerned with things that change quickly (like wind speed), a higher number might be fine.

Once you have these settings properly configured, Virtual Weather Station will export a .CSV file containing all your sensor data as often as you specify. The next step is getting that data into Powerhome.

Getting Data Into Powerhome

In order to get Virtual Weather Station data into Powerhome, you’ll need to use a macro that opens the .CSV file, grabs a bit of data, and sticks it in a global variable. First, go to the Powerhome Explorer, click on Global Variables, and create new variables for each of the weather station values you’re planning to import (temp, humidity, windspeed, etc.) Next, go to Macros and create a new macro that you’ll run when you want weather station data.

The first thing that this macro needs to do is to find and open up the .CSV file. To do this, create a new step in the Macro. For the boxes, add Set System | [LOCAL 1] | ph_readfile(“C:\The path to your .CSV file”). This loads the .CSV file into the system variable LOCAL 1.

Next, you need Powerhome to grab data from the .CSV file for each global variable. A .CSV file is simply a set of values seperated by commas (Thus Comma Seperated Values), so referencing those commas is the best way to tell Powerhome where to find what it needs. You do this using regular expresssions, which can get kind of complicated. Luckily, the regular expression that you need for this task isn’t too bad–you just need to know where your data is within the .CSV file. To figure this out, open the file in Notepad. You will set a bunch of numbers with no explanation.

To figure out what number does with which piece of data, go into VWS and find the chunk of weather data that you’re looking for, then locate the corresponding number in the .CSV file. For example, if you’re looking for temperature and the temperature is 80 degrees at the moment, find the number 80 in the .CSV file. For each piece of weather data, make a note of the location of the data piece within the .CSV file. Expanding on the temperature example, if the .CSV file looks like this: 45, 56.7, 23, 42, 80, temperature would be number 5. Find the location number for each piece of data that you’re going to grab–you’ll need those numbers later.

Next, go back to the macro. Add a step, and for the boxes enter Set Global | (One of your global variables) | ph_regexsnap(“.Next, copy the following expression: [0-9\.]*, and continously paste it until the number of copies of the expression corresponds with the location number for the global variable you’re trying to set. Finally, finish off the code with this: \([0-9\.]*\),”,”[LOCAL1]”,1,0). For the temperature example, your final macro step would look like this: Set Global | Temperature | ph_regexsnap(“[0-9\.]*,[0-9\.]*,[0-9\.]*,[0-9\.]*,[0-9\.]*,\([0-9\.]*\),”,”[LOCAL1]”,1,0)

Basically, all this is doing is telling Powerhome “grab the stuff that’s located between the fifth comma”. Once you have the basic format, simply set up another macro step for each glocal variable, changing the number of [0-9\.]*, to correspond to the chunk of data you want. When you run the macro, Powerhome should load data from Virtual Weather Station into the Global Variables.

Using the Data

Once you have dynamically updating weather data in Powerhome, you can do whatever you want with it. For example, you could create an email alert that would warn you when the inside temperature drops below a certain level, protecting your house from accidental freezes. Also, if you have a furnace control set up, you can us the sensor data to turn on the heat if the temperature drops too much.

Humidity data is useful too–in the winter, stick a humidifier into an appliance module and set up a macro that turns it on automatically when the indoor humidity gets too low (an ideal indoor humidity is around 40%–in the winter it can get down to 12 or 15). In the summer, do the same thing in reverse with a dehumidifier. Lastly, you can use your weather data to alert you to potential dangers. For example, you could set up a macro that flashes the lights when the wind speed gets too high. There are lots of possibilities.

Download a sample version of the weather station macro here.

ATTRIBUTION: The excellent method described above for using regular expressions to grab VWS data was developed by DHoward of the Powerhome Message Board

Scroll To Top