From 818f86809b8566fff1686b8553eb7a6d71e92704 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 31 Oct 2021 12:58:28 +0100 Subject: [PATCH] Fix ESP32 core 2.0.1rc1 I2C stability Fix ESP32 core 2.0.1rc1 I2C stability by performing new function wire.end() cleaning up SHT driver initiated GPIO changes. This solves HTU driver issue. --- tasmota/support.ino | 10 ++++++++++ tasmota/xsns_07_sht1x.ino | 1 + 2 files changed, 11 insertions(+) diff --git a/tasmota/support.ino b/tasmota/support.ino index c5f6078ed..b94161c33 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -2010,6 +2010,16 @@ bool I2cBegin(int sda, int scl, uint32_t frequency) { return result; } +bool I2cEnd(void) { + bool result = true; +#ifdef ESP32 +#if ESP_IDF_VERSION_MAJOR > 3 + result = Wire.end(); +#endif +#endif + return result; +} + #ifdef ESP32 bool I2c2Begin(int sda, int scl, uint32_t frequency = 100000); bool I2c2Begin(int sda, int scl, uint32_t frequency) { diff --git a/tasmota/xsns_07_sht1x.ino b/tasmota/xsns_07_sht1x.ino index 5b5419648..d9ff9639f 100644 --- a/tasmota/xsns_07_sht1x.ino +++ b/tasmota/xsns_07_sht1x.ino @@ -165,6 +165,7 @@ void ShtDetect(void) sht_type = 1; AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_I2C D_SHT1X_FOUND)); } else { + I2cEnd(); I2cBegin(sht_sda_pin, sht_scl_pin); sht_type = 0; }