TEMPer (Temperature sensor 413d:2107) on Linux tutorial

Software builded and deployed on Fedora 31 and Centos 7


Update 2020-11-25:

A beter script on Centos88 is:


exec 5<> /dev/hidraw1
echo -e ‘\x00\x01\x80\x33\x01\x00\x00\x00\x00\c’ >&5
OUT=$(dd count=1 bs=8 <&5 2>/dev/null | xxd -p)
CTEMP=$(bc <<< “scale=2; $DVAL/100”)
echo $CTEMP

source:  https://gist.github.com/artms/5356eafcd1244c6fabc0f735e5de7096




updated: 2019-11-13

There are several expensive solution to monitor room temperature, rely on cloud solutions or maybe you need to pick up the soldering iron. There is an alternative on the market that comes cheap: The TEMPer device. It can be bought from Ebay or big known e-commerce websites like dx.com. I bought my TEMPer devices (413d:2107)  from Ebay for 8,58 USD each.

To be able to successfully deploy a TEMPer device you need to have a little knowledge how to compile C code and Linux. To monitor properly the room temperature you want to use an USB extension cord.

The sellers I bought the hardware from are:

Step 1: Look up the device USB ID

There are several TEMPer devices sold as the same. They all do the same job, however be aware that the USB ID’s are different. Currently the 413:2107 is being sold and does not work out of the box with code to be found on the internet. Since I’m having the 413:2107 I’ll explaining how to make it work. I do not have the other versions. USB ID’s can be found with:

$ lsusb

If it is correct, there will be a rule containing this: Bus 006 Device 003: ID 413d:2107 , to be sure we also verify this with dmesg. You will find the following rules:

$ dmesg
input: HID 413d:2107 as /devices/pci0000:00/0000:00:10.0/usb6/6-2/6-2:1.0/0003:413D:2107.0003/input/input13
hid-generic 0003:413D:2107.0003: input,hidraw1: USB HID v1.11 Keyboard [HID 413d:2107] on usb-0000:00:10.0-2/input0
hid-generic 0003:413D:2107.0004: hiddev97,hidraw2: USB HID v1.10 Device [HID 413d:2107] on usb-0000:00:10.0-2/input1

If both are verified we are good to go and know that Linux recognizes the TEMPer device.


Step 2: Get the developer Distro packages needed to compile the TEMPer software

$ sudo dnf install hidapi-devel bc

Step 3: Git clone the needed software

$ sudo -i
$ cd /opt/
$ git clone https://github.com/edorfaus/TEMPered
$ cd TEMPered
$ cmake .
$ cd /opt/TEMPered/utils
$ make
$ cp hid-query /usr/local/bin

Step 4: Find out which hidraw device is our TEMpered device by trying to get metrics out of it:

$ ./hid-query /dev/hidraw1 0x01 0x80 0x33 0x01 0x00 0x00 0x00 0x0
No data was read from the device (timeout).

./hid-query /dev/hidraw2 0x01 0x80 0x33 0x01 0x00 0x00 0x00 0x00
Device /dev/hidraw2 : 413d:2107 interface 1 : (null) (null)

Writing data (9 bytes):

00 01 80 33   01 00 00 00 00

Response from device (8 bytes):

80 80 0a 21   4e 20 00 00

Our TEMPered device is allocated at /dev/hidraw2


Step 5: Create TEMPered script

$ vi TEMPered

OUTLINE=”/usr/local/bin/hid-query /dev/hidraw2 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]\) .*$/0x\1\2/'”
DVAL=$(( 16#$HEX4 ))
CTEMP=$(bc <<< “scale=2; $DVAL/100”)
echo $CTEMP

$ chmod +x TEMPered


Test the script:

$ ./TEMPered


This is ‘all’ it takes to make it working. I tested the TEMPered sensor next to an analogue temperature sensor and the values matched. Unfortunately this script needs to be executed as root.

21 thoughts on “TEMPer (Temperature sensor 413d:2107) on Linux tutorial

  1. To avoid running the script as root, I suggest this udev rule (all on one line):

    SUBSYSTEMS==”usb”, ACTION==”add”, ATTRS{idVendor}==”413d”, ATTRS{idProduct}==”2107″, MODE=”666″

    Works on a debian 9 machine running 4.14 kernel.
    I put this into /etc/udev/rules.d/99-tempsensor.rules

  2. Works great on Ubuntu 18.04 once I fixed all the backward quotes.
    For Ubuntu you need to install libhidapi-dev:
    sudo apt-get install libhidapi-dev
    then compile as you outlined.
    Thank you for this post!

  3. Having a problem in centos 7 using either line at
    ./hid-query /dev/hidraw

    gets this response

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

    Write failed: (null)

    • Try to play with hidraw device nummers. Here I have 3 and only one works (hidraw0% hidraw1% hidraw2%)

      Also it is worth noting that maybe SElinux is blocking it. Check this with: $ sudo audit2allow -a

      • It responded to /dev/hidraw4
        But now when executing the TEMPer script I get
        ./TEMPered: line 5: 16#ho: value too great for base (error token is “16#ho”)
        (standard_in) 1: syntax error


  4. The difference I see is in the dmesg output.
    [591817.570035] usb 6-2: New USB device found, idVendor=413d, idProduct=2107, bcdDevice= 0.00
    [591817.570040] usb 6-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
    [591817.576427] input: HID 413d:2107 as /devices/pci0000:00/0000:00:1d.0/usb6/6-2/6-2:1.0/input/input12
    [591817.627401] hid-generic 0003:413D:2107.0006: input,hidraw3: USB HID v1.11 Keyboard [HID 413d:2107] on usb-0000:00:1d.0-2/input0
    [591817.630411] hid-generic 0003:413D:2107.0007: hiddev0,hidraw4: USB HID v1.10 Device [HID 413d:2107] on usb-0000:00:1d.0-2/input1

    note: usb-0000:00:1d.0-2/input0

  5. Good Day
    I keep getting this error even though I have corrected all the backward quotes. I am running Ubuntu 16.04.

    ./TEMPered: line 5: 16#ho: value too great for base (error token is “16#ho”)
    (standard_in) 1: syntax error

        • Did some scripting on my own, based on the work described above, so here is my version. You can divide by 100 if you need to

          /usr/local/bin/hid-query /dev/hidraw1 0x01 0x80 0x33 0x01 0x00 0x00 0x00 0x00|grep -A1 ^Response|tail -1 > /tmp/temper
          sed -i -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]\) .*$/0x\1\2/’ -e ‘s/[a-z]/\U&/g’ /tmp/temper
          hex=$(cat /tmp/temper)
          printf ‘%d\n’ $hex > /tmp/temper
          echo $(date +%H:%M)”,””$(cat /tmp/temper)” >> path/to/file

  6. Thanks. Now have this device working on CentOS 7.8, Fedora 31 and ClearOS 7.7 (a derivative of CentOS)
    Had the usual problem with back ticks and single quotes 🙂

  7. Hi Maikel
    First glitch – rebooted the system and the device changed from /dev/hidraw1 to /dev/hidraw3. Now using “/usr/local/bin/hid-query -e” to check which is active to use…

    My script version can be downloaded from https://www.sraellis.tk/TEMPered/TEMPered
    Wonder if this is a user code page problem?

    see also



  8. Just to show the device detection used here, pretty simplistic and could be better written – but this does the job. Is now part of my script…

    device=`/usr/local/bin/hid-query -e | grep “413d:2107 interface 1” | awk ‘{print $1}’`


  9. You can avoid hid-query and stay in bash:
    exec 5\ /dev/hidraw1
    echo -e ‘\x00\x01\x80\x33\x01\x00\x00\x00\x00\c’ >&5
    OUT=$(dd count=1 bs=8 /dev/null | xxd -p)
    CTEMP=$(bc <<< "scale=2; $DVAL/100")
    echo $CTEMP

Leave a Reply

Your email address will not be published. Required fields are marked *