Skip to content

Commit

Permalink
Merge branch 'urwen-sht20'
Browse files Browse the repository at this point in the history
  • Loading branch information
eode committed Sep 20, 2024
2 parents e4303c1 + 09e7a0e commit 9db549b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ TEMPer | 1a86:e025 | TEMPerGold_V3.4 | I | | Metal
TEMPer | 3553:a001 | TEMPerGold_V3.5 | I | | Metal
TEMPerHUM | 413d:2107 | TEMPerX_V3.1 | I | I | White plastic
TEMPerHUM | 1a86:e025 | TEMPerHUM_3.9 | | I | White plastic with blue button
TEMPerHUM | 0c45:7402 | TEMPer1F_H1V1.5F | I | I | White plastic with blue button
TEMPer2 | 413d:2107 | TEMPerX_V3.3 | I,E | | White plastic
TEMPer2 | 1a86:e025 | TEMPer2_V3.7 | I,E | | White plastic with red button
TEMPer2 | 1a86:e025 | TEMPer2_V3.9 | I,E | | White plastic with red button
Expand Down
19 changes: 18 additions & 1 deletion temper.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,23 @@ def _read_hidraw(self, device):
#Bytes 5-6 hold the device humidity, divide by 100
self._parse_bytes('internal humidity', 4, 100.0, bytes, info)
return info
if info['firmware'][:16] == 'TEMPer1F_H1V1.5F':
info['firmware'] = info['firmware'][:16]
self._parse_bytes('internal temperature', 2, 1, bytes, info, verbose=self.verbose)
self._parse_bytes('internal humidity', 4, 1, bytes, info, verbose=self.verbose)
# The values are not aligned to the byte boundary, so shift them. And
# then apply the equations from the SHT20 data sheet.
t = int(info['internal temperature']) << 2
if self.verbose:
print(f'Raw temperature: {t}')
t = -46.85 + 175.72 * t / 65536
info['internal temperature'] = t
h = int(info['internal humidity']) << 4
if self.verbose:
print(f'Raw humidity: {h}')
h = -6 + 125.0 * h / 65536
info['internal humidity'] = h
return info
if info['firmware'][:12] == 'TEMPer2_V4.1':
info['firmware'] = info['firmware'][:12]
self._parse_bytes('internal temperature', 2, 100.0, bytes, info)
Expand Down Expand Up @@ -331,7 +348,7 @@ def _is_known_id(self, vendorid, productid):
return True
return False

if vendorid == 0x0c45 and productid == 0x7401:
if vendorid == 0x0c45 and (productid == 0x7401 or productid == 0x7402):
return True
if vendorid == 0x413d and productid == 0x2107:
return True
Expand Down

0 comments on commit 9db549b

Please sign in to comment.