Skip to content

Commit

Permalink
change order of auto detection
Browse files Browse the repository at this point in the history
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
  • Loading branch information
winkj committed Nov 14, 2023
1 parent 9831264 commit 5e89ae8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions SHTSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,15 @@ float SHT3xAnalogSensor::readTemperature()
//

const SHTSensor::SHTSensorType SHTSensor::AUTO_DETECT_SENSORS[] = {
SHT4X, // IMPORTANT: SHT4x needs to be probed before the SHT3x, since they
// share their I2C address, and probing for an SHT3x can cause the
// first reading of and SHT4x to be off.
// see https://github.com/Sensirion/arduino-sht/issues/27

SHT2X,
SHT3X,
SHT3X_ALT,
SHTC1,
SHT4X
SHTC1
};
const float SHTSensor::TEMPERATURE_INVALID = NAN;
const float SHTSensor::HUMIDITY_INVALID = NAN;
Expand Down

0 comments on commit 5e89ae8

Please sign in to comment.