Untitled

Submitted by reeses on Thu, 2003-02-06 05:51.

There we go! :-)

I stopped off at the nearest Radio Shack on the way home for a piece of cabling that cannot have any other acceptable use -- it's a 20'-ish length of 4-conductor phone cable, one RJ-11 plug on one end, and two RJ-11 sockets on the other. If you used this for its purported use, you'd have an ugly cabling mess. However, this is perfect for running a 1-wire network behind the couch, and sprouting off two sensors.

Now, if you look here, you'll see a pretty simple display of the current temperature and a historical graph over the past 24 hours, for both the indoor and outdoor sensors.

If "bodge" didn't apply before, it definitely does now.

Let me explain the moving parts necessary to generate these pages, and keep in mind that it's this convoluted because I wanted to get it up as soon as possible.

1) A Ruby script sleeps for ten minutes, then fires off a C program that polls all of the sensors on the network, and prints out their ID and reading.

2) The output is read and parsed, and sent to a Ruby script on the server, which searches the blog page and the temp page for HTML sentinel comments marking the insertion points for temperature readings and timestamp, replacing the old values with the current values.

3) The Ruby script back in the apartment then inserts the temperature readings into a simple MySQL table.

4) The Ruby script fires off an NT batch file that pulls out the last readings from the last 24 hours, for each sensor, and stores them in two files, one for each sensor. I use a batch file to avoid the quote-escaping nastiness for the inline SQL that would be necessary in Ruby or shell.

5) The batch file also fires off gnuplot with a script that sets up the graph parameters, and plots the data for the past 24 hours, producing two PBM files.

6) The batch file executes cjpeg, converting each PBM file into a jpeg.

7) The Ruby script sends these jpegs to the server via scp.

Now, what's interesting is that I'm using a bunch of tools (gnuplot, mysql, Ruby, scp, ssh, cjpeg) that are much more comfortable on various Unix systems than they are on Windows. However, they're my hammers, and this is my nail. In addition, some of the pieces that I would have otherwise written in pure Ruby depend on Windows modules that are not available, or available only by contorting my installation unacceptably.

So, there you have it. If you have 1-wire gear and want to do something similar and want a starting off point, email me. Otherwise, these are never going to see the light of day, and are going to do their ugly job unacknowledged and unlauded.

Post new comment

Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.