From a02d2e2e113df3bef6fc69c8929784d9b039b509 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 3 Jan 2022 16:37:21 +0100 Subject: [PATCH] Explicitly use overloaded begin() for I2C master initialization (#2978) Arduino 2.0.1 and newer support slave and master mode. The two modes have a begin() method with different signature: ``` // Slave Begin bool TwoWire::begin(uint8_t addr, int sdaPin, int sclPin, uint32_t frequency) // Master Begin bool TwoWire::begin(int sdaPin, int sclPin, uint32_t frequency) ``` Use type casting to make sure that overloaded method for master mode is used. --- esphome/components/i2c/i2c_bus_arduino.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/i2c/i2c_bus_arduino.cpp b/esphome/components/i2c/i2c_bus_arduino.cpp index eac2a47524..b605928692 100644 --- a/esphome/components/i2c/i2c_bus_arduino.cpp +++ b/esphome/components/i2c/i2c_bus_arduino.cpp @@ -25,7 +25,7 @@ void ArduinoI2CBus::setup() { wire_ = &Wire; // NOLINT(cppcoreguidelines-prefer-member-initializer) #endif - wire_->begin(sda_pin_, scl_pin_); + wire_->begin(static_cast(sda_pin_), static_cast(scl_pin_)); wire_->setClock(frequency_); initialized_ = true; if (this->scan_) {