From 262d69308dc45f9ec133ad9aae532dad81efaa8f Mon Sep 17 00:00:00 2001 From: Martin <25747549+martgras@users.noreply.github.com> Date: Wed, 22 Sep 2021 19:08:42 +0200 Subject: [PATCH] fix i2c scanning eror for Arduino (#2364) --- esphome/components/i2c/i2c_bus_arduino.cpp | 5 ++--- esphome/components/i2c/i2c_bus_esp_idf.cpp | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/esphome/components/i2c/i2c_bus_arduino.cpp b/esphome/components/i2c/i2c_bus_arduino.cpp index aba412c3f7..40d8049617 100644 --- a/esphome/components/i2c/i2c_bus_arduino.cpp +++ b/esphome/components/i2c/i2c_bus_arduino.cpp @@ -33,9 +33,8 @@ void ArduinoI2CBus::dump_config() { if (this->scan_) { ESP_LOGI(TAG, "Scanning i2c bus for active devices..."); uint8_t found = 0; - for (uint8_t address = 1; address < 120; address++) { - auto err = readv(address, nullptr, 0); - + for (uint8_t address = 8; address < 120; address++) { + auto err = writev(address, nullptr, 0); if (err == ERROR_OK) { ESP_LOGI(TAG, "Found i2c device at address 0x%02X", address); found++; diff --git a/esphome/components/i2c/i2c_bus_esp_idf.cpp b/esphome/components/i2c/i2c_bus_esp_idf.cpp index 4b93b41877..8bf97b63ec 100644 --- a/esphome/components/i2c/i2c_bus_esp_idf.cpp +++ b/esphome/components/i2c/i2c_bus_esp_idf.cpp @@ -43,8 +43,8 @@ void IDFI2CBus::dump_config() { if (this->scan_) { ESP_LOGI(TAG, "Scanning i2c bus for active devices..."); uint8_t found = 0; - for (uint8_t address = 1; address < 120; address++) { - auto err = readv(address, nullptr, 0); + for (uint8_t address = 8; address < 120; address++) { + auto err = writev(address, nullptr, 0); if (err == ERROR_OK) { ESP_LOGI(TAG, "Found i2c device at address 0x%02X", address);