From a7230af6d748a407b0194d86c1e93e86dc06d03e Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 13 Oct 2019 16:59:03 +0200 Subject: [PATCH] i2c scan with low speed --- src/i2cscan.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/i2cscan.cpp b/src/i2cscan.cpp index c80c2af7..d6e7ff64 100644 --- a/src/i2cscan.cpp +++ b/src/i2cscan.cpp @@ -15,9 +15,11 @@ int i2c_scan(void) { // block i2c bus access if (I2C_MUTEX_LOCK()) { + // Scan at 100KHz low speed + Wire.setClock(100000); + for (addr = 8; addr <= 119; addr++) { - // scan i2c bus with no more to 100KHz Wire.beginTransmission(addr); Wire.write(addr); i2c_ret = Wire.endTransmission(); @@ -58,6 +60,9 @@ int i2c_scan(void) { ESP_LOGI(TAG, "I2C scan done, %u devices found.", devices); + // Set back to 400KHz + Wire.setClock(400000); + I2C_MUTEX_UNLOCK(); // release i2c bus access } else ESP_LOGE(TAG, "I2c bus busy - scan error");