Skip to content

Commit 5e89ae8

Browse files
committed
change order of auto detection
Since the SHT3x and SHT4x share addresses, there's an issue when an SHT4x is connected to the bus and we're probing for an SHT3x: The result is that the first reading of the SHT4x is off. The other direction works (probing for a 4x when a 3x is connected), as such we're simply changing the order of detection
1 parent 9831264 commit 5e89ae8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

SHTSensor.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,15 @@ float SHT3xAnalogSensor::readTemperature()
350350
//
351351

352352
const SHTSensor::SHTSensorType SHTSensor::AUTO_DETECT_SENSORS[] = {
353+
SHT4X, // IMPORTANT: SHT4x needs to be probed before the SHT3x, since they
354+
// share their I2C address, and probing for an SHT3x can cause the
355+
// first reading of and SHT4x to be off.
356+
// see https://github.com/Sensirion/arduino-sht/issues/27
357+
353358
SHT2X,
354359
SHT3X,
355360
SHT3X_ALT,
356-
SHTC1,
357-
SHT4X
361+
SHTC1
358362
};
359363
const float SHTSensor::TEMPERATURE_INVALID = NAN;
360364
const float SHTSensor::HUMIDITY_INVALID = NAN;

0 commit comments

Comments
 (0)