Monday, 24 August 2015

linux thermometer

Without shame, some of this was copied from 

http://verahill.blogspot.co.uk/2013/12/532-temper-temperature-monitoring-usb.html

:)  Thanks for your work!  



sudo apt-get install python-usb python-setuptools snmpd git
sudo easy_install snmp-passpersist
mkdir ~/tmp
cd ~/tmp
git clone git://github.com/padelt/temper-python.git
cd temper-python/
sudo python setup.py install

sudo temper-poll

Generates a result!  But it needs sudo.

Figure out which /dev/bus/usb device this is, then change the owner of this `file` from root to me:

$ lsusb

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 014: ID 0781:5567 SanDisk Corp. Cruzer Blade
Bus 001 Device 015: ID 0c45:7401 Microdia 
Bus 001 Device 004: ID 1058:1123 Western Digital Technologies, Inc. My Book 3.0
Bus 001 Device 126: ID 046d:c077 Logitech, Inc. 
Bus 001 Device 125: ID 413c:2107 Dell Computer Corp. 
Bus 001 Device 124: ID 2109:3431  
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

The interesting device is Bus 001 Device 015.

$ ls -lha /dev/bus/usb/001/
total 0
drwxr-xr-x  2 root root      180 Aug 24 10:16 .
drwxr-xr-x 10 root root      200 Jul 14 12:14 ..
crw-rw-r--  1 root root 189,   0 Jul 14 12:14 001
crw-rw-r--  1 root root 189,   3 Jul 15 17:20 004
crw-rw-r--  1 root root 189,  13 Aug  6 14:56 014
crw-rw-r--  1 root root 189,  14 Aug 24 16:14 015
crw-rw-r--  1 root root 189, 123 Jul 14 12:17 124
crw-rw-r--  1 root root 189, 124 Jul 14 12:17 125
crw-rw-r--  1 root root 189, 125 Jul 14 12:17 126

There it is:

$ sudo chown me /dev/bus/usb/001/015

And now I can access the device without sudo.  :)

Will that work after unplugging?  No!  The permissions are gone...

$ sudo vim /etc/udev/rules.d/80-temper.rules


SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7401",
GROUP="users", MODE="0666"
Unplug,

sudo service udev restart

Plug back in.  

Now for something really neat from the site above:  Setup a cron job to grab the temperature, log it, plot the data.

**************************************8

After all that, I'm getting only one temperature value and it's from the sensor inside the device:  not the remote one.  It's the remote one that I'm interested in.  Some reading around suggests there are other libraries:  let's see.

https://pypi.python.org/pypi/hidapi/0.7.99-5


No comments:

Post a Comment