After toying with the idea for a couple of years, I finally got started on setting up a 1-Wire network in my house to collect temperatures in each of my rooms. The long delay in getting started with this project is almost entirely from having trouble in finding definitive information regarding what I needed, so I hope to accomplish that here.
A 1-Wire network is pretty simple: Connect a 1-Wire adapter to a PC, and connect that adapter to the network, be it a hub which connects multiple 1-Wire network segments, or a single 1-Wire run, as you can have multiple 1-Wire devices on a single run.
My setup looks like this:
Server - 1-Wire Serial Adapter - 6 Channel Hub - Two DS18S20s (one on two of the 6 channels of the hub, this leaves me room to expand 4 more channels. You can also daisy-chain multiple sensors on a single run).
I am using standard CAT5e Eithernet cable for my 1-Wire network; the DS18S20 has 3 pins, two of which are used. The first pin connects to the white-green wire, and the second to the blue wire. I will add some more info here later, but it is really that simple.
Connecting it to your PC
I am running Linux on my server. After wiring up the network and connecting it to the serial adapter, and the adapter to my PC, it was time to get started.
Digitemp is used to communicate with 1-Wire networks, it has been around for a while, and it works.
Make sure everything works
- We're using a DS9097U serial adapter, so I symlinked the binary for ease of use.
- Setup the initial config file. My serial adapter was on /dev/ttyS0, your's may be on /dev/ttyS1.
- Get some actual data.
That third line should produce output similar to this:
Super! Things work. Now I'd like to start storing this data in a database, so that I can do neat things with it later (like trending graphs). Make sure mysql is installed (apt-get install mysql-server). I am using cron to call a perl script which calls digitemp and stores the data in a database (apt-get install libdbi-perl libdbd-mysql-perl)
Now just put this in a cronjob to be called every 5 minutes, and you're golden!