I use this setup to monitor a server room, and as a weatherstation.
This project consists of:
- A Dallas 1-Wire bus network
- Interface between RS-232 and the Dallas 1-Wire system
- Digital temperature sensors connected to the Dallas 1-Wire bus (DS1820/DS18s20)
- Software setup to gather and graph temperatures
Step 1: You Need
- Some linux skills
- Basic electronics skills, soldering etc..
- 1 6.2V Zener diode (1N5234)
- 1 3.9V Zener diode (1N5228)
- 2 Schottky diodes (1N5818)
- 1 1.5 k resistor
- 1 2pin screw terminal
- 1 D-sub 9 female connector with solder points
- 1 small piece of perfboard.
- One or more Dallas Semiconductor DS1820 or DS18s20 digital temperature sensor
- Cat5 cabling
- Shrink tube
Step 2: Build the RS232 Interface
Figure out how small you can make it.
Put all the components on a perfbaord. Place them with the circuit in mind. We don't want to add any wires to the bottom of the circuit! Se image.
Cut out the right size perfboard.
Just drag a sharp knife a few times over the row of holes where you want to cut.
Do this on both sides, then just break it in two. It usually breaks at the fault line you created.
Solder the components in place. and connect the solder points to complete the circuit.
Step 3: Testing the RS232 Interface
Download and install digitemp.
On Debian and Ubuntu Linux, this is done by running `sudo apt-get install digitemp`.
Connect a DS1820 to your circuit.
The middle leg goes in the DQ port, the other two legs go in GND
Connect the circuit to a computers rs232 port.
I only cover doing this with Linux, but it is also possible to do this in windows..
If the command `digitemp` doesnt work, it's because there are multiple versions of digitemp.
type digitemp, then press tab to see all of them.. digitemp_DS9097 is the right one for this 1wire busmaster.
Just for the sake of simplicity, we want the command to be `digitemp`, not `digitemp_DS9097`.
type `sudo ln -s /usr/bin/digitemp_DS9097 /usr/bin/digitemp`
As root, or using sudo:
Run `digitemp -s /dev/ttyS0 -i`. This searches the 1wire network for sensors, and creates a config file for digitemp. If you are using COM2, use -s /dev/ttyS1.
Run `digitemp -a` to read the temperature of the connected tempsensor.
See the screenshot
Do this for all the sensors you are going to use, and write down the addresses for each one.
When you have multiple sensors, it's nice to know which is which.
Step 4: Make the Sensors and the Network
I have had some bad experiences using other cables, and with combining different types of cable.
When running over cat5, the 1wire bus can have quite long cables.
In one weatherstation setup, I run a 30 meter cat5 from a technical room with a Linux computer and up to the roof. On the roof, the cable is split into 3 5-15 meter long cables with a sensor at the end of each one. This setup works flawlessly. The 1-wire network is quite robust.
Making the sensor:
You want to make the sensor both waterproof, and rigid.
Cut a Cat 5 cable to the desired length.
De-insulate the sensor end.
Cut off 3 of the 4 pairs, leaving the green/whitegreen one.
Slide a small shrink tube over the green wire.
Solder the green wire to the middle pin of the DS1820
Pull the the shrink tube up, so it covers all the metal of the middle leg and the metal of the wire connected to it. Then heat it with a lighter or heat gun to shrink it in place
Solder the white/green wire to the two other pins.
Put a larger shrink tube over the sensor and the cable.
See the picture.
Then heat it gently with a lighter to shrink in place.
You don't want to set the thing on fire, just hold the flame 4-10mm away from the shrink tube.
Put your sensors wherever you want to have them, connect to the rs232 interface and plug into your computer.
Step 5: Software Setup - Data Acquisition
As root on your linux machine:
Run `digitemp -s /dev/ttyS0 -i -c /etc/digitemp.conf`
This creates the config file digitemp.conf with yoru sensors.
Watch the output to see what number the sensors get.
Check the temperature with `digitemp -aq -c /etc/digitemp.conf`
Dump the output data into a file. I dump to a file within apaches wwwroot, that way I can access the temperature from anywhere.
The command `digitemp -aq -c /etc/digitemp.conf > /var/www/digitemp.txt` puts the output of digitemp into the file digitemp.txt
Automate this process:
type `crontab -e`, this opens roots crontab.
Type `* * * * * digitemp -aq -c /etc/digitemp.conf > /tmp/digitemp; mv /tmp/digitemp /var/www/digitemp.txt` into that file, and save it.
Run `crontab -l` to confirm that the crontab has been installed.
The reason I am piping the output into /tmp and then moving it to /var/www, is that digitemp uses a few seconds to compete its run. If you try to access the output while digitemp is running, you would get an incomplete file. This could mess up other scripts that read data from this file. (This is not included in the screenshot, forgot to do it)
Your weatherstation is now up and running.
Use the data to do whatever you like, graph it, use it to email in case of high/low temp, etc..
Step 6: Software Setup - Graphing
Make a place to put the scripts, a place to store the images, and a place to store the data.
You will need, PHP and RRDtool.
`apt-get install rrdtool`
`apt-get install php` (there are many php packages, install one with a console executable)
Download and install the scripts responsible for makin the graphs:
Download tempsensor-0.1.tar.gz to your linux machine.
`tar xvzf tempsensor-0.1.tar.gz`
`cp -v tempsensor/* /etc/tempsensor`
Configure the scripts
Open /etc/tempsensor/config.php and follow the comments in this file.
Change the script to read input data from "/var/www/digitemp.txt" if you followed the example in the previous step.
Add a crontab entry the same way as in the previous step. The script should run every 5th minute.
The lines should look like this:
`*/5 * * * * php /etc/tempsensor/logdata.php`
`*/5 * * * * php /etc/tempsensor/graphdata.php`
Run the scripts manually to check if it works.
Visit http://your.ip.or.hostname/temperature or whatever you specified in the config file.
Step 7: Implementation 1 - Server Room Monitoring
Step 8: Implementation 2 - Weather Station
The weatherstation is a bit trickier than the serverroom.
There is a lot of interference outside.
The sun may hit a sensor, sending it from -1 to 30 c in 5 minutes.
I solved this by using three sensors placed at points which would receive sunlight at different times during the day. Since heat is the only "noise" in the measurement, I just use the sensor with the lowest reading at any time as my "outside temperature".
This temperature is again smoothed by averaging the last few minutes.