diff --git a/esphome/components/i2c/i2c_bus_esp_idf.cpp b/esphome/components/i2c/i2c_bus_esp_idf.cpp index c7bba70582..c5d6dd8b2a 100644 --- a/esphome/components/i2c/i2c_bus_esp_idf.cpp +++ b/esphome/components/i2c/i2c_bus_esp_idf.cpp @@ -8,6 +8,10 @@ #include "esphome/core/helpers.h" #include "esphome/core/log.h" +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0) +#define SOC_HP_I2C_NUM SOC_I2C_NUM +#endif + namespace esphome { namespace i2c { @@ -17,14 +21,14 @@ void IDFI2CBus::setup() { ESP_LOGCONFIG(TAG, "Setting up I2C bus..."); static i2c_port_t next_port = I2C_NUM_0; port_ = next_port; -#if SOC_I2C_NUM > 1 +#if SOC_HP_I2C_NUM > 1 next_port = (next_port == I2C_NUM_0) ? I2C_NUM_1 : I2C_NUM_MAX; #else next_port = I2C_NUM_MAX; #endif if (port_ == I2C_NUM_MAX) { - ESP_LOGE(TAG, "Too many I2C buses configured. Max %u supported.", SOC_I2C_NUM); + ESP_LOGE(TAG, "Too many I2C buses configured. Max %u supported.", SOC_HP_I2C_NUM); this->mark_failed(); return; }