The setup of my 1-Wire network

Introduction

DISCLAIMER:  This post was copied from my old web page and is a bit old.  Some information contained within this post may be out of date.
In my home automation setup, I wanted to be able to monitor temperature in various places around my house as well as outdoors.  I wanted a solution that was relatively cheap and easy to use.  My brother some time back had mentioned to me about something called 1-Wire.  He had used it up at his cabin to monitor temperature and electric usage through current sensing.  I did a bit of searching and found that it fit both of my needs, cheap and easy to set up.  So I figured I would document my setup here.

The 1-wire interface

1-wire adapterThe first thing I needed to run this was some type of 1-Wire computer interface.  After looking at options, I came across the DS9097U adapter on Ebay.  Unlike other 1-Wire adapters that had an RJ11 jack for connecting the sensors, this model had 2 - 3.5 mm headphone style jacks on it.  It did come with an adapter to connect the RJ11 style sensors if needed.  It looked like that adapter would fit the bill perfectly.  I ended up purchasing one for around $20.00 US from a china distributor on Ebay.

The sensors

The next thing I was going to need was some of the 1-Wire temperature sensors.  My brother had mentioned that he got all of his equipment from a company called Hobby Boards.  I checked their website and I could buy the bare temperature sensors for about $4.50, but they wanted $10.00 for shipping.  I decided to check Ebay.  I figured that if I could get the adapter cheap, I should be able to get the sensors cheap too.  I ended up finding another chinese distributor that sold the sensors in packs of 5 for around $7.00 shipped.  A pack of 5 of them from Hobby Boards would have been about $40.00 shipped, so I went for the Ebay deal (who wouldn't at that price), so I bought a pack of 5 just to try things out.

The build

Now that I had all the parts, I needed to figure out how to wire things up.  Looking at the data sheet, I saw that there were 2 ways to wire these devices.  The first was using parasite power.  This is basically powering the device from power it grabs from the 1-wire network.

The other way was to use an external 5 volt power source.

So, if I was to use the external power source, how would I accomplish this.  I once again turned to Hobby Boards who had a how to section that outlined a wiring specification that used cat5 wire, and supplied a regulated 5 volts along with an unregulated 12-24 volts on the wire for use down the line for other devices.  The color scheme shown here is using the ISO T568A standard.  Most cat5 cables that you buy these days use the ISO T568B specification which is what I am using.  The only noticeable difference is that the orange and green wire pairs are reversed putting the color order at, white orange, orange, white green, etc... 

I figured using a documented wiring spec would be more reliable, mainly because it has been tested and used by others.  Not to mention if I wanted to add other devices from Hobby Boards, I can do it without having to re-wire things.

Now that I had a wiring specification planned out, I had to figure out the temperature sensor nodes.  Using the information from the DS18B20 data sheet, I devised a simple circuit that allowed me the option of using parasite power or external power.  Using a jumper on a 3 position header I was able to quickly switch between the 2 if needed.  In the schematic shown to the left, placing the header jumper across pins 2 and 3 will run the sensor on parasite power.  Conversely, by placing the jumper on pins 1 and 2, I could run it on the 5 volt external power.

Since the majority of the nodes were going to be in the house on walls, I wanted something that wasn't going to look unsightly on the wall.  I ended up finding someone that was throwing out some old vented covered wall boxes.  I then put together a couple of these circuits on some perfboard.  I even made an etched board that although it turned out good took too much time.  The perfboard versions were much easier to do in the small quantity that I needed, and they worked just as well.  To the right is one of my perfboard sensors mounted on the wall plate ready to be installed.  I connected each one individually and used the software that came with the 1-Wire adapter to get the built in hardware address of each sensor and labeled each one.

The installation

Now that I had a few of these built, it was time to install them around my house.  To start, I installed one in the master bedroom, orne in the spare bedroom and one outside on the outer edge of my deck.  I wired these up with the cat5 wire just stripped and screwed to the terminal block using the blue pair and the solid orange wire.  Though  this works, my issue with it right now is that none of the connections pass the other wire pair signals down the line, like the 12-24 volt power.  For now, this is not an issue, but I do have a plan for fixing it which I still need to implement. The idea is to use an RJ45 splitter adapter similar to the one shown to the left.  By crimping modular plugs to the ends of each cable coming to the temp sensors and plugging them into the 2 jacks on the adapter, this will pass all signal and power lines through. I can then clip the wire that comes off of the adapter and use it to connect to the temp sensor or whatever other sensor I try to install.

The only other hurdle to attack in this project is to get things set up in my automation software.  This was insanely easy.  I installed the 1-Wire plugin for OSA and after plugging the sensors into the adapter, OSA sent a 1-wire search ROM signal which automatically detects any sensors attached to the 1-Wire bus.  OSA then automatically added these as objects to the system.  All I needed to do then is to add them to my floorplan view and make use of them in the system.

I started with the outdoor sensor.  Looking at my RCS thermostat a while back, I noticed that it had an option for displaying the outdoor temperature on the wall display keypad.  Since I wrote the OSA plugin for it, I simply added an option for taking the temperature value from any other OSA object and sending it to the thermostat.  Now if I want to know the temperature outside, I just look at my thermostat.

I wanted to do more than just use these to display the temperature on a wall display.  My next thing to tackle was to use the value from my master bedroom sensor to aid in controlling a booster fan that I have attached to my furnace.  The booster fan was originally set up to come on any time the furnace or central air turned on.  I thought that this was a waste of energy, so I set up a script to say if it is between 9:00 PM and 1:00 AM, and the temperature in the room is below 68° in the room when the furnace kicks in, then turn on the booster fan.  This is so that the room is warmed up a bit when we go to bed.  I will do something similar for the summer months and using the air conditioner.  Now I have some real world energy saving with the system.  Though not much, i'd suspect, it is something.

I have recently installed two of these in my bar/man cave area in my basement.  The room is very long with a fireplace at one end.  My plan is to monitor both temp sensors and when the one closest to the fireplace shows a temp that is 3 or more degrees higher than the one on the other end of the room, it would turn on a fan to circulate the air in the room.  The fan would then stay on until the temperature normalized throughout the basement.

One more thing that I plan on doing which I have not yet set up is to put a system in place for humidity control in my bathroom.  The idea is to install a 1-Wire temperature and humidity sensor in the bathroom.  I will then install a controller on my vent fan that I can turn on when the humidity gets too high.  The fan would then stay on long enough for the humidity to get to a safe level.  The idea behind this is to control mold and mildew buildup in the bathroom.

Conclusion

There are many other uses for 1-Wire in a home automation setup.  Implemented correctly, many of these can save you time money and cleanup costs.  I have not even scratched the surface of things I can do with this, and I plan to do a lot more over time.

Related Images:

Adding HVAC overlays to MisterHouse

Introduction

DISCLAIMER: This is an old topic that I migrated from my old website due to the traffic it used to get.  I no longer use MisterHouse for my automation, so I will not be able to answer any questions regarding this topic.  Some of this information may be out of date, but may still work.

indoor temperatures graph

For some time now I have been using the MisterHouse automation software with my Raspberry Pi as my main automation software.  One of the features that I use is the weather data from the internet_weather.pl common code module.  I also have an RCS-TR40 RS485 thermostat and 7 one-wire temperature sensors throughout the house that I use with this setup also.  The weather module has a graphing feature that allows me to graph the indoor temperatures from my one-wire sensors.  A sample of this is shown to the right.  Though this was a nice feature, there was somehting missing.  I wanted a visual representation of my HVAC operation overlayed on the graph.  I saw a perfect example of what I was looking for on Marc Merlin's blog site marc.merlins.org/perso/homeha/2009-12.html.  About 1/4 of the way down the page you will see the 2 graphs.  Marc uses cacti with RRD to get his results, but I was using a module in MisterHouse that did not have this functionality.  This post shows the steps I took to modify the code in the weather module to be able to do this.

The Code Modification for HVAC Overlays

Before performing any of the steps described here, it is always a good idea to make backups of the files that you are modifying in the event that you need to revert back.  With that said, let's proceed.

The main file that you will need to modify is the weather_rrd_update_graphs file located in the MisterHouse/bin folder of your installation.  When I made the modifications to my setup, I had to start a new RRD database file because of the way that I modified the file.  I am going to show you how to do this in a way that SHOULD NOT affect your current RRD database.

The first step is to locate the section of code that defines the default color codes for the graphs.  In my file, this started at line 44.  Depending on the number of HVAC zones and whether you want to show heating, cooling or both for these zones, this will determine the number of tempspares that you will want to sacrifice for this.  In my setup I only have single zone heating and cooling, so I would only need to hijack $tempspare9 and $tempspare10.  The default color codes used for 9 and 10 are "66FFFF" and "0000CC" respectively.  These will need to be changed.  I used "FF6F7D88" (9) for the heating color, and "6F87FF88" (10) for the cooling color.  One thing you will notice that is different with these 2 values is that they are longer than the original values with the added "88" at the end of each. This is very important as the last 2 hex values are the transparency values.  This is what allows the HVAC color bars to be overlayed over thetemperature line graphs and still have them visible.

The next part is a bit tricky.  You will need to remove the tempspare RRD DEFinitions for whatever $tempspares you are using for this.  In my setup I would remove tempspare9 and tempspare 10 DEFs.  For each tempspare, you will need to remove 6 lines of code.

1 ."\"DEF:mintempspare9=$RRD:tempspare9:MIN\","
2 .($weather_uom_temp eq 'C' ? "\"CDEF:fmintempspare9=mintempspare9,32,-,5,9,/,*\"," : "\"CDEF:fmintempspare9=mintempspare9\",")
3 ."\"DEF:maxtempspare9=$RRD:tempspare9:MAX\","
4 .($weather_uom_temp eq 'C' ? "\"CDEF:fmaxtempspare9=maxtempspare9,32,-,5,9,/,*\"," : "\"CDEF:fmaxtempspare9=maxtempspare9\",")
5 ."\"DEF:tempspare9=$RRD:tempspare9:AVERAGE\","
6 .($weather_uom_temp eq 'C' ? "\"CDEF:ftempspare9=tempspare9,32,-,5,9,/,*\"," : "\"CDEF:ftempspare9=tempspare9\",")

Now, where you deleted these lines of code, you will add 2 lines for each tempspare you are replacing.

1
."\"DEF:tempspare9=$RRD:tempspare9:AVERAGE\","
2 ."\"CDEF:ftempspare9=tempspare9,1,EQ,INF,UNKN,IF\","

Next, you will need to change the LINE2 definitions for your tempspares to AREA plots.  Find the following lines:
. ($sensor_names{tempspare9} ? "\"LINE2:... :'')

Remove the "LINE2" and "GPRINT" lines from each and replace with this:

"\"AREA:ftempspare9#${colortempspare9}:" . sprintf("%-${max}s",$sensor_names{tempspare9}) . "\","

For the last code modification, you need to edit the weather_rrd_update.pl file in "misterhouse/code/common/".  Look for this block of code:

if($config_parms{weather_uom_temp} eq 'C') {
grep { $_=convert_c2f($_) unless $_ eq 'U' } ($rrd_TempOutdoor, $rrd_TempIndoor,
$rrd_TempSpare1, $rrd_TempSpare2, $rrd_TempSpare3, $rrd_TempSpare4,
$rrd_TempSpare5, $rrd_TempSpare6, $rrd_TempSpare7, $rrd_TempSpare8,
$rrd_TempSpare9, $rrd_TempSpare10, $rrd_DewOutdoor, $rrd_DewIndoor,
$rrd_DewSpare1, $rrd_DewSpare2, $rrd_DewSpare3, $rrd_TempOutdoorApparent
);
}

You will need to remove all references to TempSpareXX that you are converting.  If not done, this could prevent the HVAC bars from showing up if you have your user configuration "weather_uom_temp" set to "C"elsius.

HVAC overlays user code additions

Now you need to define things in your user code.  This will vary for each setup as thermostats and/or ways of identifying that the furnace or AC is on are done differently in each setup.  This is basically how I have it set up in my user code:

# Define the weather hash's initial starting HVAC values
if ($Startup or $Reload) {
    $Weather{TempSpare9}  = int(0);
    $Weather{TempSpare10} = int(0);
}

#### Now, if your furnace is on tempspare 9, the code will be something like this: ####
if ($RCS_current_state eq 'heat') {
# Tell the weather hash that the furnace is on
$Weather{TempSpare9} = int(1);
} else {
# Tell the weather hash that the furnace is off
$Weather{TempSpare9} = int(0);
}

Last, you can tweak your setup in your mh.private.ini file adding your own sensor names for each tempspare that you set up.  You can also tweak the colors of your displayed bars from here the same as your other sensors.  Remember though, if you change color values in your mh.private.ini file, you NEED to add the transparency value to each color.  I found 88 to be a good transparency value for me, but your situation may differ.

Below is a sample output of my setup with the furnace overlays in place.

Related Images: