TEMPer with ID 413d:2107

- Rolf Strathewerd

I actually had something very simple in mind: connect a temperature sensor to my RasPi and observe the ups and downs of the temperature in our apartment for a long time. I liked the TEMPer: it’s cheap and there’s support for Linux (but not from the manufacturer, it only comes with some grotesque Windows software).

When the thing arrived from China a few days after the order, I first looked at what I had.

lsusb delivered

[...]
Bus 001 Device 005: ID 413d:2107  
[...]

That was a USB ID, which was rather unusual for this thing. That didn’t promise anything good.

The basic drivers can be found at https://github.com/signal11/hidapi and have to be compiled by yourself. This is all well described there, but here is my summary:

Clone the repository first …

git clone git://github.com/signal11/hidapi.git

… then install the requirements for later compilation …

 sudo apt-get install libudev-dev libusb-1.0-0-dev libfox-1.6-dev autotools-dev autoconf automake libtool

… and perform the build steps

./bootstrap.
./configure
make
sudo make install  

At this point we are not finished yet, we need a second project for the temperature sensors, which can be found at https://github.com/edorfaus/TEMPered

Cloning the repository again (parallel to the hidapi project; this simplifies the following steps) …

<font color="#ffff00">-=https://github.com/edorfaus/TEMPered.git=- proudly presents

… then install the requirements for later compilation …

sudo apt install cmake

… and finally perform the build steps

cmake .
make

In utils is now hid-query, with which you can list the connected devices:

hid-query -e
/dev/hidraw0 : 413d:2107 interface 0 : (zero) (zero)
/dev/hidraw1 : 413d:2107 interface 1 : (zero) (zero)

To find out how to get the values, send a prompt to the two devices (here hidraw0 and hidraw1) one after the other

sudo hid-query /dev/hidraw0 0x01 0x80 0x33 0x01 0x01 0x00 0x00 0x00 0x00 0x00

In my case, the request “hung” from one device and gave the following answer for the other:

Writing data (9 bytes):
         00 01 80 33 01 00 00 00 00

Response from device (8 bytes):
         80 80 0b from 4e 20 00 00

Unfortunately tempered does not know this version of the stick yet. Because I was too lazy I was in the C code, I got from the various postings to the issues on github I got the code to a small bash script, which together outputs the current temperature to Human_Interface_Device hid-query. You may have to install bc first:

sudo apt install bc

Then all you need is a little script …

#!/bin/bash
OFFSET=0.0
OUTLINE=`sudo hid-query /dev/hidraw1 0x01 0x80 0x33 0x01 0x00 0x00 0x00 0x00|grep -A1 ^Response|tail -1`
OUTNUM=`echo $OUTLINE|sed -e 's/^[^0-9a-f]*[0-9a-f][0-9a-f] [0-9a-f][0-9a-f][0-9a-f] \([0-9a-f][0-9a-f]\) \([0-9a-f][0-9a-f]\) .*$/0x\1\2/'`
HEX4=${OUTNUM:2:4}
DVAL=$$(( 16#$HEX4 ))
bc <<< "scale=2; $DVAL/100 - $OFFSET"

… and you have the current temperature … almost. Because first you have to check the result with a good thermometer, then the stick has a constant offset to the real temperature. As soon as you know the difference you should adjust the 0.0 in the script.

One last note: The stick should not be used directly on a computer, but have some distance by means of an extension cable. Otherwise the computer heats the stick. and the measurements are pointless.

Translated with www.DeepL.com/Translator


Feedback gerne per eMail an mail@scaldra.net oder per XMPP an scaldra@trashserver.net