Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for product ID 413d:2107 #84

Open
kenkma opened this issue Jan 25, 2018 · 24 comments
Open

Support for product ID 413d:2107 #84

kenkma opened this issue Jan 25, 2018 · 24 comments

Comments

@kenkma
Copy link

kenkma commented Jan 25, 2018

Most recent sensors seems to have a new ID, 413d:2107.

Has anyone successfully hacked the code to work with it?

this C hack seems to work.

edorfaus/TEMPered#51

Thank you.

@Estebastien
Copy link

Yes same need. I have a TEMPerX232 (thermo-hygrometer) with that ID and I can't make it work as my others Temper1F.
I have no clue. I don't really now what magic is going on in these hacks. I added the new ID to the VIPDS list, and of course I get an error ("Entity not found").
Thank you

@mreymann
Copy link

mreymann commented Feb 7, 2018

Hi I use temper-python with my Microdia TEMPer Temperature Sensor (0c45:7401) and it works like a charm. I, as well, was too adventurous when buying an obscure "TEMPerHUM" (413d:2107). It would be great to have support for this device in temper-python!

Thanks for your work!

@mreymann
Copy link

mreymann commented Feb 16, 2018

I've created a working Munin plugin for our device using hid-query: https://github.com/mreymann/temperx
Support should be fairly easy to implement in temper-python. USB commands seem to be very similar. I have a PCAP file here if anybody needs it.

@ndemou
Copy link

ndemou commented Jun 1, 2018

Hoping that this comment will help temper-python to support devices with id 413d:2107 I should note that running this hid-query gives you the temperature (hid-query is part of https://github.com/edorfaus/TEMPered more info bellow):

./hid-query /dev/hidraw1 0x01 0x80 0x33 0x01 0x00 0x00 0x00 0x00
...
Response from device (8 bytes):
         80 80 09 0e   4e 20 00 00     <--- temperature is 0x090e/100

P.S. Until temper-python supports them here's a complete set of commands to print the temperature:

DEVID=/dev/hidraw1 # use `hid-query --enum` to find the right DEVID
OUTLINE=`./hid-query $DEVID 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/'`
echo $(( 16#$OUTNUM ))|awk '{printf("%4.1f\n",$0/100)}'
23.1°C

The above are 99% based on TEMPered#51 "hack" from digiboule mentioned above.

To install TEMPered (that contains the hid-query utility) download it and see this post edorfaus/TEMPered#35 (comment)

P.S.3: I must admit that I'm really confused by who forked what version of TEMPered to support which device type.

P.S.4: Here's a copy of my bash session that ended up on the above commands:

root@lion:~/manual-install/TEMPered-master/utils#  lsusb
...
Bus 004 Device 002: ID 413d:2107  
...
root@lion:~/manual-install/TEMPered-master/utils# ./hid-query --enum
/dev/hidraw0 : 413d:2107 interface 0 : (null) (null)  #<---note the device ids (/dev/hidrawX)
/dev/hidraw1 : 413d:2107 interface 1 : (null) (null)

# I will try to read from the first device id
root@lion:~/manual-install/TEMPered-master.TafThorne/build/utils# ./hid-query /dev/hidraw0 0x01 0x80 0x33 0x01 0x00 0x00 0x00 0x00
Device /dev/hidraw0 : 413d:2107 interface 0 : (null) (null)

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

No data was read from the device (timeout).

# Well this device id didn't work, let's try the other one:
root@lion:~/manual-install/TEMPered-master/utils# ./hid-query /dev/hidraw1 0x01 0x80 0x33 0x01 0x00 0x00 0x00 0x00
Device /dev/hidraw1 : 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 09 0e   4e 20 00 00

# perfect so /dev/hidraw1 is the device id that does work!

@jbeale1
Copy link

jbeale1 commented Jun 17, 2018

As I mentioned at edorfaus/TEMPered#35 (comment) I have one of these new 413d:2107 devices which the Windows "TEMPer V26.1" software calls "Firmware: TEMPerGold_V3.1" and mine is I think temperature only, although the hidapi testgui app shows two devices with that VID:PID. The eight-byte hex string posted by ndemou above, does work when manually entered from the hidapi testgui. However the TEMPered project "hid-query" tool does not see the device at all (only sees my keyboard and mouse) so I don't know how to script this.

@ndemou
Copy link

ndemou commented Jun 17, 2018

@jbeale1: mine is also temperature only and if you notice in the transcript above I also see two devices and one of them doesn't respond.

@jbeale1
Copy link

jbeale1 commented Jun 17, 2018

It does work! After keyboard and mouse, it's hidraw3 on my system. Also needs 'sudo'

 sudo ./hid-query /dev/hidraw3 0x01 0x80 0x33 0x01 0x00 0x00 0x00 0x00
Device /dev/hidraw3 : 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 08 4d   4e 20 00 00

@jbeale1
Copy link

jbeale1 commented Jun 17, 2018

Edit: awk works for float division, or after doing "sudo apt-get install bc"

#!/bin/bash
OUTLINE=`sudo ./hid-query /dev/hidraw3 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/'`
HEX4=${OUTNUM:2:4}
DVAL=$(( 16#$HEX4 ))
bc <<< "scale=2; $DVAL/100"

@jbeale1
Copy link

jbeale1 commented Jun 17, 2018

Bash script to print time & temp every ~15 sec, with readTEMPer.sh being my script in above comment:

while [ true ]; do
  temp=`/usr/local/bin/readTEMPer.sh`
  echo $(date +"%F %T") " , " $temp
  sleep 14
done

example output:

2018-06-17 11:45:23  ,  24.50
2018-06-17 11:45:38  ,  24.43
2018-06-17 11:45:52  ,  24.25
2018-06-17 11:46:07  ,  24.12
2018-06-17 11:46:21  ,  23.93

@ndemou
Copy link

ndemou commented Jun 17, 2018

Thanks @jbeale1 for noticing the bug with integer arithmetic. I fixed my script (just used awk instead of bc because it works perfectly for such low precision calculations and is pre-installed almost everywhere)

@jbeale1
Copy link

jbeale1 commented Jun 17, 2018

On my raspberry pi, 'awk' is apparently mawk 1.3.3 and it always gives me 0.0 for example:

awk "BEGIN {printf(\"%4.1f\n\",0x0891/100)}"
 0.0

awk -W version
mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan

Edit: after 'sudo apt-get install gawk' then it all works as intended.

@ndemou
Copy link

ndemou commented Jun 17, 2018

Right again. A cross platform way seems to be

echo $(( 16#891 ))|awk '{printf("%4.1f\n",$0/100)}'

(I've updated my script)

@schniepp
Copy link

schniepp commented Jun 19, 2018

I also have a 413d:2107 device. It is supposed to do both T and R.H.: vendor, Amazon. By pressing the button, I can get it to operate like a keyboard and just dump its output to /dev/stdin. So I know it works, and it puts out T and R.H. in a human readable way. But that's not really practical.

My biggest issue right now is that hid-query /dev/hidraw3 0x01 0x86 0xff 0x01 0x00 0x00 0x00 0x00 gives me this error: Write failed: (null). I am doing this as root, and hid-query detects it successfully. Is this perhaps a slightly different device? Does it need a different string sent? Or is something about permissions set up the wrong way, so that writing does not work?

I should add that my device is called "TemperX232". I know that some other devices also use the same 413d:2107 USB identifier (for instance the newer "TemperHum" devices).

@ndemou
Copy link

ndemou commented Jun 19, 2018

@schniepp have you tried all devices that hid-query --enum returns?

@schniepp
Copy link

Yes. The other two ones are only my external keyboard and mouse. The one that I am using reports the correct USB ID.

@jbeale1
Copy link

jbeale1 commented Jun 19, 2018

After logging for two days, I see the output of my TEMPer has a nominal 0.06 C resolution. I haven't done a careful calibration, but the plot shows big flat spots at fixed values like it gets stuck. It is not, but clearly it can not reliably measure changes smaller than 0.5 C. Example plot: https://photos.app.goo.gl/HEiZdxNJTLN1RLUf7
For about the same price, the "USB DS18B20" probe on ebay may work better. At least there's apparently a working linux package.

@cmsimike
Copy link

cmsimike commented Jul 6, 2018

I received a 413d:2107 from amazon, and though it reports two USB devices (keyboard/USB device), I can only seem to get data from the usb device. I don't have a button to send keyboard input. The temp it reports back is way too high to make sense. It was commented elsewhere that there is an internal and external temp that can be reported. I'm worried that I'm only seeing the internal temp, if that's the case.

@Proxx
Copy link

Proxx commented Aug 21, 2018

same here, got the 413d:2107 version and really like to see this usbstick supported 😄

@cmsimike
Copy link

cmsimike commented Aug 21, 2018

I am currently using this script to read the raw USB values from the 413d:2107

#!/bin/bash
OUTLINE=`/root/dev/TEMPered/build/utils/hid-query /dev/hidraw3 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/'`
HEX4=${OUTNUM:2:4}
DVAL=$(( 16#$HEX4 ))
CTEMP=$(bc <<< "scale=2; $DVAL/100")
FTEMP=$(echo "scale=2;((9/5) * $CTEMP) + 32" |bc)

I built TEMPered, and it has an hid-query, which I can use to get the raw sensor values.

@schniepp
Copy link

schniepp commented Oct 16, 2018

This totally fixed my problems: urwen/temper.
It's a pure python3 program that makes my device work. The author also describes in the README.md that the access via hidraw does not work and gives errors. Brilliant! I can use my device now!!! The author also has listed a table with different devices.

What brought me on this track: the Firmware version using the Windows software reads as "TEMPerX232_V2.0".

@Poikilos
Copy link

Poikilos commented Jan 21, 2021

This totally fixed my problems: urwen/temper.
It's a pure python3 program that makes my device work. The author also describes in the README.md that the access via hidraw does not work and gives errors. Brilliant! I can use my device now!!! The author also has listed a table with different devices.

What brought me on this track: the Firmware version using the Windows software reads as "TEMPerX232_V2.0".

A fork of it has several improvements. It also has a setup.py so it can be installed in a virtualenv preferably (in a terminal) like:

python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel
python -m pip install --upgrade https://github.com/ccwienk/temper/archive/master.zip
  • not to be confused with the unrelated project on pypi (pip install temper without the link above will mess things up)
  • Please use the --user option along with each command if not using a virtualenv (to avoid messing up your copy of Python).

And used as a module instead of a command (in Python) like:

from temper import Temper
tmpr = Temper()
if not hasattr(tmpr, 'usb_devices'):
    print("You have the wrong temper. Get ccwienk/temper (or the old urwen/temper).")
devices = tmpr.read()
for i in range(len(devices)):
    print("{} C".format(devices[i]['internal temperature']))

@acs4design
Copy link

acs4design commented Oct 21, 2022

I was able to get my Temper2 device working in windows. You will need to download libusb-1.0.26-binaries and unzip it in the project directory. For windows, this is what I needed. This device is VID 0x431D PID 0x2107. There is no product name in the USB descriptor, so there's no good way to tell it apart from any of the others except for VID/PID. It does have 2 endpoints. The first is a keyboard endpoint. The other is the temperature interface. This device has a button on it. It has an internal temp measurement and an external measurement probe. To get both sensor readings, you write the USB commands for init, then send USB command to read temp, then complete 2 reads. The first read is the internal temp (offset 2 in the 8 byte data) then divide by 100.0. The second read is the external temp (offset 2 in the 8 byte data) then divide by 100.0.

I've attached a modified temper.py file. I'm sorry it is such a hack, but I just needed something quick. This at least gives the coders maintaining this to potentially add it. Though I'm not sure if it'll work since all the others have product names. This one does not and that is how they are differentiated in the code. This one is definitely different than the others. Again, my apologies for the hack job of this beautiful code, but I also wanted to give back since this gave me a great starting point.
temper.py.zip

@davet2001
Copy link
Collaborator

@acs4design Thanks for sharing this. Is your sensor like one of the ones here?:

https://usb-ids.gowdy.us/read/UD/413d/2107

Please could you double check the description strings to see if there's anything uniquely identifiable about the sensor that we can use to select the correct decoding?

I don't have one of these sensors so I'm also looking for someone who can help me with testing a patch for this new sensor.

@acs4design
Copy link

acs4design commented Oct 27, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests