diff --git a/CHANGELOG.md b/CHANGELOG.md index ed9ade0a19b1..4ce6f0948269 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. - I2C bus2 support to SHTxX temperature and humidity sensor - I2C bus2 support to HYTxxx temperature and humidity sensor - I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor +- I2C bus2 support to LM75AD temperature sensor ### Breaking Changed diff --git a/I2CDEVICES.md b/I2CDEVICES.md index 981ae465b8ba..1a8500954b3f 100644 --- a/I2CDEVICES.md +++ b/I2CDEVICES.md @@ -40,7 +40,7 @@ Index | Define | Driver | Device | Address(es) | Bus2 | Descrip 19 | USE_SI1145 | xsns_24 | SI1145 | 0x60 | Yes | Ultra violet index and light sensor 19 | USE_SI1145 | xsns_24 | SI1146 | 0x60 | Yes | Ultra violet index and light sensor 19 | USE_SI1145 | xsns_24 | SI1147 | 0x60 | Yes | Ultra violet index and light sensor - 20 | USE_LM75AD | xsns_26 | LM75AD | 0x48 - 0x4F | | Temperature sensor + 20 | USE_LM75AD | xsns_26 | LM75AD | 0x48 - 0x4F | Yes | Temperature sensor 21 | USE_APDS9960 | xsns_27 | APDS9960 | 0x39 | | Proximity ambient light RGB and gesture sensor 22 | USE_MCP230xx | xsns_29 | MCP23008 | 0x20 - 0x26 | | 8-bit I/O expander 22 | USE_MCP230xx | xsns_29 | MCP23017 | 0x20 - 0x26 | | 16-bit I/O expander diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 979261865292..2e58c19c8651 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -120,6 +120,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - I2C bus2 support to SHTxX temperature and humidity sensor - I2C bus2 support to HYTxxx temperature and humidity sensor - I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor +- I2C bus2 support to LM75AD temperature sensor ### Breaking Changed diff --git a/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino b/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino index b8c2711805f1..502deb515421 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino @@ -47,31 +47,30 @@ bool lm75ad_type = false; uint8_t lm75ad_address; +uint8_t lm75ad_bus; uint8_t lm75ad_addresses[] = { LM75AD_ADDRESS1, LM75AD_ADDRESS2, LM75AD_ADDRESS3, LM75AD_ADDRESS4, LM75AD_ADDRESS5, LM75AD_ADDRESS6, LM75AD_ADDRESS7, LM75AD_ADDRESS8 }; -void LM75ADDetect(void) -{ - for (uint32_t i = 0; i < sizeof(lm75ad_addresses); i++) { - lm75ad_address = lm75ad_addresses[i]; - if (!I2cSetDevice(lm75ad_address)) { - continue; // do not make the next step without a confirmed device on the bus - } - uint16_t buffer; - if (I2cValidRead16(&buffer, lm75ad_address, LM75_THYST_REGISTER)) { - if (buffer == 0x4B00) { - lm75ad_type = true; - I2cSetActiveFound(lm75ad_address, "LM75AD"); - break; +void LM75ADDetect(void) { + for (lm75ad_bus = 0; lm75ad_bus < 2; lm75ad_bus++) { + for (uint32_t i = 0; i < sizeof(lm75ad_addresses); i++) { + lm75ad_address = lm75ad_addresses[i]; + if (!I2cSetDevice(lm75ad_address, lm75ad_bus)) { continue; } // do not make the next step without a confirmed device on the bus + uint16_t buffer; + if (I2cValidRead16(&buffer, lm75ad_address, LM75_THYST_REGISTER, lm75ad_bus)) { + if (buffer == 0x4B00) { + lm75ad_type = true; + I2cSetActiveFound(lm75ad_address, "LM75AD", lm75ad_bus); + return; + } } } } } -float LM75ADGetTemp(void) -{ +float LM75ADGetTemp(void) { int16_t sign = 1; - uint16_t t = I2cRead16(lm75ad_address, LM75_TEMP_REGISTER); + uint16_t t = I2cRead16(lm75ad_address, LM75_TEMP_REGISTER, lm75ad_bus); if (t & 0x8000) { // we are getting a negative temperature value t = (~t) +0x20; sign = -1; @@ -80,14 +79,13 @@ float LM75ADGetTemp(void) return ConvertTemp(sign * t * 0.125f); } -void LM75ADShow(bool json) -{ +void LM75ADShow(bool json) { float t = LM75ADGetTemp(); if (json) { ResponseAppend_P(JSON_SNS_F_TEMP, "LM75AD", Settings->flag2.temperature_resolution, &t); #ifdef USE_DOMOTICZ - if (0 == TasmotaGlobal.tele_period) DomoticzFloatSensor(DZ_TEMP, t); + if (0 == TasmotaGlobal.tele_period) { DomoticzFloatSensor(DZ_TEMP, t); } #endif // USE_DOMOTICZ #ifdef USE_WEBSERVER } else {