Open joshuachen3333 opened 8 years ago
it seems that we could trick the code somewhere at libtempered/type_hid/common.c to allow more compatible string ID to pass through before it is formally supported, But I am too old (too long ago) coding the C driver, Could someone help?
Cheers Joshua
When I ran tempered I got the following response:
/dev/hidraw6: Could not open device: Unknown device subtype string: TEMPer1F_H1V1.5F
However this is the following output from lsusb -v -s
us 003 Device 075: ID 0c45:7402 Microdia TEMPerHUM Temperature & Humidity Sensor Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0c45 Microdia idProduct 0x7402 TEMPerHUM Temperature & Humidity Sensor bcdDevice 0.01 iManufacturer 1 RDing iProduct 2 TEMPer1F_H1_V1.4 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 59 bNumInterfaces 2 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 1 Boot Interface Subclass bInterfaceProtocol 1 Keyboard iInterface 0 HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.10 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 65 Report Descriptors: \ UNAVAILABLE Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 10 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 1 Boot Interface Subclass bInterfaceProtocol 2 Mouse iInterface 0 HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.10 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 41 Report Descriptors: \ UNAVAILABLE Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 10 can't get device qualifier: Resource temporarily unavailable can't get debug descriptor: Resource temporarily unavailable Device Status: 0x0000 (Bus Powered)
After a bit of playing around I added the following to temper_type.c, and recompiled:
(struct temper_subtype*)&(struct temper_subtype_hid){
.base = {
.id = 0x02 ,
.name = "TEMPer1F_H1V1.5F",
.open = tempered_type_hid_subtype_open,
.read_sensors = tempered_type_hid_read_sensors,
.get_temperature = tempered_type_hid_get_temperature,
.get_humidity = tempered_type_hid_get_humidity
},
.sensor_group_count = 1,
.sensor_groups = (struct tempered_type_hid_sensor_group[]){
{
.query = {
.length = 9,
.data = (unsigned char[]){ 0, 1, 0x80, 0x33, 1, 0, 0, 0, 0 }
},
.read_sensors = tempered_type_hid_read_sensor_group,
.sensor_count = 1,
.sensors = (struct tempered_type_hid_sensor[]){
{
.get_temperature = tempered_type_hid_get_temperature_si7005,
.get_humidity = tempered_type_hid_get_humidity_si7005,
.temperature_high_byte_offset = 2,
.temperature_low_byte_offset = 3,
.humidity_high_byte_offset = 4,
.humidity_low_byte_offset = 5
}
}
}
}
},
Running tempered produced the following result:
/dev/hidraw6 0: temperature 153.62 °C, relative humidity 87.7%, dew point 148.9 °C
So it's reading the device but not returning the right results.
Change the following lines:
.get_temperature = tempered_type_hid_get_temperature_si7005,
.get_humidity = tempered_type_hid_get_humidity_si7005,
to:
.get_temperature = tempered_type_hid_get_temperature_sht1x,
.get_humidity = tempered_type_hid_get_humidity_sht1x,
Because in this humidity usb sensor the SHT20 sensor is used. I think that should work.
Using the following patch:
diff --git a/libtempered/temper_type.c b/libtempered/temper_type.c
index 1b00b20..ab416f9 100644
--- a/libtempered/temper_type.c
+++ b/libtempered/temper_type.c
@@ -37,6 +37,7 @@ struct temper_type known_temper_types[]={
.subtype_strings = (char *[]){
"TEMPerHumV1.0rHu",
"TEMPerHumM12V1.0",
+ "TEMPer1F_H1V1.5F",
NULL
}
},
@@ -103,6 +104,37 @@ struct temper_type known_temper_types[]={
}
}
},
+ (struct temper_subtype*)&(struct temper_subtype_hid){
+ .base = {
+ .id = 0x02 ,
+ .name = "TEMPer1F_H1V1.5F",
+ .open = tempered_type_hid_subtype_open,
+ .read_sensors = tempered_type_hid_read_sensors,
+ .get_temperature = tempered_type_hid_get_temperature,
+ .get_humidity = tempered_type_hid_get_humidity
+ },
+ .sensor_group_count = 1,
+ .sensor_groups = (struct tempered_type_hid_sensor_group[]){
+ {
+ .query = {
+ .length = 9,
+ .data = (unsigned char[]){ 0, 1, 0x80, 0x33, 1, 0, 0, 0, 0 }
+ },
+ .read_sensors = tempered_type_hid_read_sensor_group,
+ .sensor_count = 1,
+ .sensors = (struct tempered_type_hid_sensor[]){
+ {
+ .get_temperature = tempered_type_hid_get_temperature_sht1x,
+ .get_humidity = tempered_type_hid_get_humidity_sht1x,
+ .temperature_high_byte_offset = 2,
+ .temperature_low_byte_offset = 3,
+ .humidity_high_byte_offset = 4,
+ .humidity_low_byte_offset = 5
+ }
+ }
+ }
+ }
+ },
NULL // List terminator for subtypes
}
},
I get the following readings:
$ examples/read-all
Device /dev/hidraw3 : USB IDs 0c45:7401, interface 1
Enumeration type name: TEMPerV1.2 or TEMPer2V1.3
Open succeeded.
Device path: /dev/hidraw3
Device type name: TEMPer2V1.3
Sensor count: 2
Sensor 0:
Temperature: 24.12°C
Sensor 1:
Temperature: 22.12°C
Device /dev/hidraw4 : USB IDs 0c45:7402, interface 1
Enumeration type name: TEMPer2HumiV1.x
Open succeeded.
Device path: /dev/hidraw4
Device type name: TEMPer1F_H1V1.5F
Sensor count: 1
Sensor 0:
Temperature: 26.51°C
Humidity: 47.1%RH
The temperature is way off; a standalone thermometer agrees with the external sensor (1) on the 1st USB device, that the temperature in the room is around 22.5°C.
Yes I have the same problem. The temperature in this senor is not very accurate :-(.
The patch from yrro fixed the issue for me. The device was received today from aliexpress. Maybe this is the new version.
I can also confirm, that the sensors are pretty bad calibrated. Temperature shown is about 3-4°C too high and humidity about 20% too high.
Just did some more tests with this device. I'm currently getting a temperature reading of 25.47 °C and a humidity reading of 49% when reading the device from Linux. However, if I plug it into a Windows system and press the button it it to activate the keyboard input function, it dutifully types out a temperature of 22.35 °C and a humidity reading of 39.9%. these readings are a lot closer to those given by the other devices I have lying around, although the temperature is still a little high. It's frustrating that the device itself seems to have calibration data locked away somewhere inside, without giving the user the ability to access it!
Hi,
Firstly, is this project still alive? I can see few quite recent comments but the last commit was about 5 years ago. There are pending pull requests starting from 2013. Is there a place with an up-to-date version? This is a wonderful source of information about the TEMPer devices.
Now, if anybody is still maintaining this project I got this device working (for another project). I don't have the time to write the driver as I do not use this project but here are all the details that are needed for someone to add the support for this device as well: pid = "0x7402", vid = "0x0C45", RDing, "TEMPer1F_H1_V1.4"
I opened the device and found an SHT20 sensor inside. As far as I know no other TEMPer device is using this sensor.
The data is read using one of the standard reading commands, { 0x01, 0x80, 0x33, 0x01, 0x00, 0x00, 0x00, 0x00 }.
The data arrives in the usual 6-byte format, the temperature high & low is at offsets 2 & 3 while the humidity is at 4 & 5. Now, the sensor outputs 14-bit temperature data which is shifted by 2 bits in the device. It needs shifting back before we can use the temperature calibration equations from the SHT20 datasheet. Similarly the humidity is shifted by 4 bits and needs shifting back as well.
The code to get the temperature and humidity may look like this (in c#):
RawReadingTemperature = (byte)(data[offsetTemperatureLow] & 0xFF) + (((byte)(data[offsetTemperatureHigh])) << 8);
RawReadingHumidity = (byte)(data[offsetHumidityLow] & 0xFF) + (((byte)(data[offsetHumidityHigh])) << 8);
// bitshift temperature by 2.
RawReadingTemperature = RawReadingTemperature << 2;
// bitshift humidity by 4.
RawReadingHumidity = RawReadingHumidity << 4;
// use equations from the SHT20 datasheet to get temperature and humidity
temperature = -46.85 + 175.72 * RawReadingTemperature / 65536;
humidity = -6 + 125 * RawReadingHumidity / 65536;
if (humidity < 0)
humidity = 0;
if (humidity > 100)
humidity = 100;
Important: The Windows software that came with the device DOES NOT work correctly. The calibration is wrong and the temperature values are a few degrees off (similar for humidity), as per comments above. The values from the Windows software DO NOT even match the values obtained by the device itself (by pressing the button on it). It looks like the Windows software is using calibration for another device which gives close but incorrect values. My approach above gives identical results as the device itself (by pressing the button on it). The readings are accurate compared to two other meters I have here.
I hope this helps someone.
Hey @axsdenied, the project seems inactive but the wiki is still a useful place to note your discoveries - assuming it's 0c45:7402 then add it to TEMPer2HumiV1.x (or maybe a separate page under 0C45:7402, since the name is different... and I admittedly haven't done this for my 1.5 device yet... 🙇)
Actually it's interesting that you note you have an SHT20 inside your device. Are the reading conversion formulas different from those of the SHT1x?. Perhaps that explains why the readings from my device are so off...
And don't worry about the Windows software--it's complete nonfunctional garbage. It doesn't run on my system, so I made the mistake of decompiling it... never again... ;)
Hi @yrro, thank you for the update. I will update the wiki.
The conversion formulas are different for SHT1x and for SHT20.
If I use the SHT1x formulas with my device the measured temperature is about 3 degrees C higher than the real temperature and also the humidity was about 10-15% higher (the difference is not constant and will vary with the ambient temperature and humidity).
This difference is similar to what you mentioned in your comments above. Chances are that your device is using SHT20 as well. You should try changing the formula to what I had above, I am curious to see if it fixes the problem.
I have added pages for SHT20 and TEMPer1F_H1_V1.x. I have also updated the page for 0C45:7402
@yrro, if your v1.5 device works with the new formulas for SHT20 you can just add it to TEMPer1F_H1_V1.x
Hello folks,
the tempered package I installed actually is functioning because I could do all utils and examples code for this one, all work. http://goods.ruten.com.tw/item/show?21439300929462
But I have another temp + external humidity usb sensor TEMPer1F H1 http://www.pcsensor.com/usb-hygrometer/temper1f_h1.html
the following problems show it is currently unspported
./enumerate Found device: 0c45:7402 1 | /dev/hidraw1 | TEMPer2HumiV1.x
./read-all Device /dev/hidraw1 : USB IDs 0c45:7402, interface 1 Enumeration type name: TEMPer2HumiV1.x Open failed, error: Unknown device subtype string: TEMPer1F_H1V1.4F
./read-repeat /dev/hidraw1 Opening /dev/hidraw1 failed, error: Unknown device subtype string: TEMPer1F_H1V1.4F
./tempered /dev/hidraw1: Could not open device: Unknown device subtype string: TEMPer1F_H1V1.4F
hid-query -e /dev/hidraw0 : 0c45:7402 interface 0 : RDing TEMPer1F_H1_V1.4 /dev/hidraw1 : 0c45:7402 interface 1 : RDing TEMPer1F_H1_V1.4
Fortunately query did get response hid-query /dev/hidraw1 1 0x80 0x33 1 Device /dev/hidraw1 : 0c45:7402 interface 1 : RDing TEMPer1F_H1_V1.4
Writing data (9 bytes): 00 01 80 33 01 00 00 00 00
Response from device (8 bytes): 80 04 19 1c 05 e6 34 46
it seems that only the subtype things unknown, the query format is actually working.
I wonder how I could go further to make it work, could someone point me out what should I do (to provide more test for you? to setup/change something you need?)
Thanks in advance.
Cheers Joshua
P.S. I am testing it in Centos 7.1 x86_64 with all git latest version of hidapi and libusbx-devel-1.0.15-4 libgudev1-219-19 cmake-2.8.11-4
dmesg said [18084.109650] usb 3-1: new low-speed USB device number 11 using xhci_hcd [18084.280555] usb 3-1: New USB device found, idVendor=0c45, idProduct=7402 [18084.280565] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [18084.280570] usb 3-1: Product: TEMPer1F_H1_V1.4 [18084.280574] usb 3-1: Manufacturer: RDing [18084.283588] usb 3-1: ep 0x81 - rounding interval to 64 microframes, ep desc says 80 microframes [18084.283604] usb 3-1: ep 0x82 - rounding interval to 64 microframes, ep desc says 80 microframes [18084.286921] input: RDing TEMPer1F_H1_V1.4 as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/input/input22 [18084.287708] hid-generic 0003:0C45:7402.0013: input,hidraw0: USB HID v1.10 Keyboard [RDing TEMPer1F_H1_V1.4] on usb-0000:00:14.0-1/input0 [18084.290523] hid-generic 0003:0C45:7402.0014: hiddev0,hidraw1: USB HID v1.10 Device [RDing TEMPer1F_H1_V1.4] on usb-0000:00:14.0-1/input1 [18185.162168] usb 3-1: USB disconnect, device number 11 [18185.508670] usb 3-1: new low-speed USB device number 12 using xhci_hcd [18185.679617] usb 3-1: New USB device found, idVendor=0c45, idProduct=7402 [18185.679628] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [18185.679634] usb 3-1: Product: TEMPer1F_H1_V1.4 [18185.679639] usb 3-1: Manufacturer: RDing [18185.680209] usb 3-1: ep 0x81 - rounding interval to 64 microframes, ep desc says 80 microframes [18185.680234] usb 3-1: ep 0x82 - rounding interval to 64 microframes, ep desc says 80 microframes [18185.684449] input: RDing TEMPer1F_H1_V1.4 as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/input/input23 [18185.685312] hid-generic 0003:0C45:7402.0015: input,hidraw0: USB HID v1.10 Keyboard [RDing TEMPer1F_H1_V1.4] on usb-0000:00:14.0-1/input0 [18185.687767] hid-generic 0003:0C45:7402.0016: hiddev0,hidraw1: USB HID v1.10 Device [RDing TEMPer1F_H1_V1.4] on usb-0000:00:14.0-1/input1