March Madness/Day 6

Rain indicator

Here's a couple of programs and a little bit of hardware to light up an LED if rain is forecast. downloads an RSS weather forecast from the BBC and parses it to try and extract the weather for today, or tomorrow if today's forecast is no longer available. It will then call either ' 255' or ' 0' depending on whether it is forecast to rain or not respectively. For testing purposes, can also take a filename as a command line argument, in which case it will use that file as its source XML rather than downloading it. The perl program is hardcoded to use "M3" as the target postcode for forecasts - you should see how to change that quite easily. should be run as a cron job, perhaps hourly. is just a small Python script which sets the output of the PC's parallel port according to the value passed in.

There's no good reason for using both Perl and Python in this project, I just started writing the parser in Perl, and later found the easiest way I could set the parallel port was using Python. The parser could be rewritten in Python quite easily.

For to work, the calling user will need to be in the 'lp' group. Run usermod -a -G lp <user> as root to add that user to the group. You'll need to log out and back in again. On my debian box, I also needed modprobe ppdev to get the /dev/parport0 device.

The LED runs off the parallel port because my server had one and it's very simple to use. There's an octal Darlington driver chip on there to run the LED, and it draws power from a spare floppy drive connector. Not many modern PCs have parallel ports, but you could use a USB interface board or something like an Arduino to connect an LED to.

Programs here as usual: