バックナンバー
もくじ
Amazonからてんぱーちゃんが届く
TEMPerで気温を測ろう
$ lsusb Bus 001 Device 004: ID 413d:2107 Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
不幸にも
ID 413d:2107
この番号が出ると険しいコース
$ sudo apt-get install build-essential libudev-dev libusb-* $ sudo apt install libusb-1.0-0-dev libudev-dev libfox-1.6-dev $ sudo apt-get install autotools-dev autoconf automake libtool cmake
git clone https://github.com/signal11/hidapi cd hidapi/linux make -f Makefile-manual sudo cp libhidapi-hidraw.so /usr/local/lib/ sudo ln -s /usr/local/lib/libhidapi-hidraw.so /usr/local/lib/libhidapi-hidraw.so.0
cd git clone https://github.com/hughesr/TEMPered cd TEMPered/ sudo git checkout hack-413d-2107 sudo git reset --hard 75aa1e2 sudo cmake . sudo make sudo make install sudo ldconfig
$ sudo tempered /dev/hidraw1 0: temperature 30.93 °C /dev/hidraw1 1: Failed to get the temperature: Not enough data was read from the sensor. /dev/hidraw1 1: no sensor data available
30.93 °C ??
$ sudo tempered 2> /dev/null | awk 'NR==1' | cut -b 17- temperature 32.43 °C
ほわー?32.43 °C ??
秋なのだが。。おかしい。
USBタップを導入する
$ sudo tempered 2> /dev/null | awk 'NR==1' | cut -b 17- temperature 26.37 °C
まともな値が出た。
数値だけにする
$ sudo tempered 2> /dev/null | awk 'NR==1' | cut -b 29-33 26.56
Pythonでスクリプトを書く
$ cat getTemper.py import subprocess from subprocess import check_output out = check_output("sudo tempered 2> /dev/null | awk 'NR==1' | cut -b 29-33", shell=True) print(out)
実行
$ python getTemper.py 26.18