Skip to content

Commit 0a124b7

Browse files
authored
Fix SHT4x detection by reading unique serial nubmer (#8525)
1 parent 7def825 commit 0a124b7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/detect/ScanI2CTwoWire.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ uint16_t ScanI2CTwoWire::getRegisterValue(const ScanI2CTwoWire::RegisterLocation
106106
if (i2cBus->available())
107107
i2cBus->read();
108108
}
109+
LOG_DEBUG("Register value: 0x%x", value);
109110
return value;
110111
}
111112

@@ -377,14 +378,13 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
377378
}
378379
case SHT31_4x_ADDR: // same as OPT3001_ADDR_ALT
379380
case SHT31_4x_ADDR_ALT: // same as OPT3001_ADDR
380-
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2);
381-
if (registerValue == 0x11a2 || registerValue == 0x11da || registerValue == 0x11f3 || registerValue == 0xe9c ||
382-
registerValue == 0xc8d) {
383-
type = SHT4X;
384-
logFoundDevice("SHT4X", (uint8_t)addr.address);
385-
} else if (getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x7E), 2) == 0x5449) {
381+
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x7E), 2);
382+
if (registerValue == 0x5449) {
386383
type = OPT3001;
387384
logFoundDevice("OPT3001", (uint8_t)addr.address);
385+
} else if (getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2) != 0) { // unique SHT4x serial number
386+
type = SHT4X;
387+
logFoundDevice("SHT4X", (uint8_t)addr.address);
388388
} else {
389389
type = SHT31;
390390
logFoundDevice("SHT31", (uint8_t)addr.address);

0 commit comments

Comments
 (0)