Article updated 28/10/2014 thanks to Pete Chapman releasing even better software. Read on!
One of the long-term goals is to pop one of my Raspberry Pi’s up in the loft. From there I plan to move my ADSB aircraft monitoring from the ‘Mancave’ into the highest point of the house; as I live up way up a hill, hopefully this will significantly improve my reception.
I also wanted to pop a temperature sensor on the mains water pipe feeding the cold water storage tank. My loft is very well insulated from the house (good for us), but also quite exposed. In a very cold winter this could result in the ambient temperature up there dropping to or below freezing. Frozen pipes, cracked tanks … not funny.
I ordered the above item from Amazon (search for PCSensor Temper1F). There are many types it seems but this is the one I’m writing about today. From what I can gather, they all function mostly the same and the instructions below should work regardless of which one you get. For the price (~£10-15) they are reportedly very accurate.
Throw away the driver CD
Firstly throw away the driver CD that comes with it. Yes it has linux software on it, but it’s buggy. Particularly for my purposes as when the temperature drops below 0C it overflows and reports 248C. Not that helpful when you wish to report on too cold rather than too hot.
Plug it in
Remove the USB stick from the packaging and plug in the temperature probe to the rear. Then use a USB extension lead to plug it in to your Pi (not mandatory, but when I use the Raspberry Pi I dislike touching the actual device and extension leads make it much easier to not disturb the device too much). If it’s the same model as mine you should get a little red LED light up.
$ dmesg | tail
[ 623.621245] usb 1-1.2: new low-speed USB device number 7 using dwc_otg [ 623.735966] usb 1-1.2: New USB device found, idVendor=0c45, idProduct=7401 [ 623.736004] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 623.736020] usb 1-1.2: Product: TEMPer1F_V1.3 [ 623.736034] usb 1-1.2: Manufacturer: RDing [ 623.757428] input: RDing TEMPer1F_V1.3 as /devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2:1.0/input/input2 [ 623.760094] hid-generic 0003:0C45:7401.0004: input,hidraw1: USB HID v1.10 Keyboard [RDing TEMPer1F_V1.3] on usb-bcm2708_usb-1.2/input0 [ 623.777723] hid-generic 0003:0C45:7401.0005: hiddev0,hidraw2: USB HID v1.10 Device [RDing TEMPer1F_V1.3] on usb-bcm2708_usb-1.2/input1
Bus 001 Device 007: ID 0c45:7401 Microdia
As I said above the existing software that comes with it is broken.
Peter Vojtek has released a fixed version of the original code on GitHub (local mirror). Pete Chapman has released an even-more fixed version of the original software, as a fork of Peter Vojtek’s code on GitHub (local mirror). While Vojtek fixed the negative temperature issue, the sub-integer (decimal) temperature values were not accurate. Pete Chapman’s code fixes that little issue as well and makes the probe even more accurate. Thanks Pete!
Go grab it, and follow me. The instructions are a bit sparse with the code but it’s not at all difficult.
- $ apt-get install build-essential libusb-dev
- $ unzip master.zip (or whatever the driver zip file is)
- $ cd usb-thermometer-master
- $ make
- $ sudo make rules-install
- Unplug and Re-Plug the Thermometer
- $ ./pcsensor
If all went according to plan and you haven’t had any errors or you’ve resolved them on the way, you should get back:
2014/10/12 13:03:35 Temperature 69.95F 21.08C
You can then use awk, or any shell script or scripting language of your choice (python example) to extract that data and make use of it. Copy the executable to /usr/local/bin when you are happy it works. Anyone on the system can execute it, it requires no special pemissions thanks to the 666 udev rules.
When you’ve got a decent amount of temperature data (the sources differ, but I put them in a uniform format in a MySQL database), you can have some fun with the data as well as more serious alerting ideas like above.