USB Temperatures Integrated with Motion Webcams
After some damn hot days 3-4 weeks back I wanted to know exactly how hot it was both inside our house and in the Mancave/shed. I found this webpage and bought way more 1-Wire sensors than needed. All up I bought 10 DS18S20′s, 9 ttl to USB convertors, 5 water proof probes (DS18S20′s included) and 2 RS-323 serial probes (DS18S20′s included).
I have 2 low powered Open-WRT devices that now have sensors connected to them via USB to TTL convertors – a wireless router and a HP T5510, both have a squeezeslave client and a security webcam.
The program used to retrieve the temperatures from the sensors is Digitemp, the output is then piped to a file on the server via NFS share. From there it gets picked up by Collectd and graphed. Another cron job sends the temperatures to Motion.
- Solder a chip to the TTL convertor (described here) and plug it into the PC/router – you may also have to download the driver for the USB convertor like I did.
- Type lsusb (lsbutils or similar is required) or dmesg, look for the convertor chipset name, then check available packages to see if you can download it easily. Example; opkg list|grep <chipset>, or maybe “aptitude search <chipset>” – depending on your OS of choice.
- Setup a share between the device and server if it’s not being saved to the same device. I used NFS, because it was already setup.
- Install and configure digitemp – available through most package managers. Followed most of this guide to setup the conf and cron job. Not all of it is required to output to a simple text file.
- Setup Collectd to use the output file as a source of information:
Exec nobody “/etc/collectd/temps.sh”
sleep “$INTERVAL”; do
VALUE1=`/usr/bin/tail -n 1 /home/public/data/temperatures/mancave`
echo “PUTVAL dcerouter/HouseTemps/temperature-House interval=$INTERVAL N:$VALUE0″
echo “PUTVAL dcerouter/HouseTemps/temperature-Shed interval=$INTERVAL N:$VALUE1″
- Create cron job to add temperatures to Motion images
/usr/bin/wget –delete-after “http://192.168.80.1:8888/1/config/set?text_left=Mancave Temp – $CONDITIONS c”
/usr/bin/wget –delete-after “http://192.168.80.1:8888/2/config/set?text_left=Kitchen Temp – $CONDITIONS c”
And now the results!
The webcam images below are from the kitchen and mancave, you can see the current temp (sampled in 5 minute increments) at the bottom left of each. The graph shows a history of the temperatures. This setup would be great for cool rooms, server rooms, and any other environment controlled room or container.
References:http://www.lavrsen.dk/foswiki/bin/view/Motion/WeatherData http://www.hoppie.nl/tempsens/ http://www.digitemp.com/ http://collectd.org/ http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome