From c6579d241f3725c90f808a1eeb8ce58715fe24f7 Mon Sep 17 00:00:00 2001 From: zdroyer Date: Mon, 14 Oct 2019 22:52:34 +0200 Subject: [PATCH] Added accepting the Si7021 sensor in the begin function as programmatically compatible with HTU21D --- Adafruit_HTU21DF.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Adafruit_HTU21DF.cpp b/Adafruit_HTU21DF.cpp index 7299081..53a2c9a 100644 --- a/Adafruit_HTU21DF.cpp +++ b/Adafruit_HTU21DF.cpp @@ -46,7 +46,10 @@ boolean Adafruit_HTU21DF::begin(void) Wire.write(HTU21DF_READREG); Wire.endTransmission(); Wire.requestFrom(HTU21DF_I2CADDR, 1); - return (Wire.read() == 0x2); // after reset should be 0x2 + uint8_t result = Wire.read(); + // after reset the result should be 0x2 for HTU21DF + // or 0x3A for Si7021, which is compatible for temp and humidity readings + return (result == 0x2) || (result == 0x3A); } /**