Call of overloaded 'begin(int, int, int)' is ambiguous

Hi every one.
The code below got error of ''
what's that means?
Thanks
adam

#include <Wire.h>
 
#define I2C_Freq 100000
 
#define SDA_0 21
#define SCL_0 22
 
#define SDA_1 18
#define SCL_1 19
 
TwoWire I2C_0 = TwoWire(0);
TwoWire I2C_1 = TwoWire(1);
 
void setup()
{
  I2C_0.begin(SDA_0 , SCL_0 , I2C_Freq );
  I2C_1.begin(SDA_1 , SCL_1 , I2C_Freq );
}

void loop() {
  // put your main code here, to run repeatedly:

}
`Preformatted text`

Arduino: 1.8.16 (Windows 7), Board: "AI Thinker ESP32-CAM, 240MHz (WiFi/BT), QIO, Huge APP (3MB No OTA/1MB SPIFFS), 80MHz, None"


C:\Users\HUA.DELLV-PC\Documents\Arduino\sketch_jun05e\sketch_jun05e.ino: In function 'void setup()':

sketch_jun05e:16:40: error: call of overloaded 'begin(int, int, int)' is ambiguous

   I2C_0.begin(SDA_0 , SCL_0 , I2C_Freq );

                                        ^

In file included from C:\Users\HUA.DELLV-PC\Documents\Arduino\sketch_jun05e\sketch_jun05e.ino:1:

C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3\libraries\Wire\src/Wire.h:79:10: note: candidate: 'bool TwoWire::begin(int, int, uint32_t)'

     bool begin(int sda=-1, int scl=-1, uint32_t frequency=0); // returns true, if successful init of i2c bus

          ^~~~~

C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3\libraries\Wire\src/Wire.h:80:10: note: candidate: 'bool TwoWire::begin(uint8_t, int, int, uint32_t)'

     bool begin(uint8_t slaveAddr, int sda=-1, int scl=-1, uint32_t frequency=0);

          ^~~~~

sketch_jun05e:17:40: error: call of overloaded 'begin(int, int, int)' is ambiguous

   I2C_1.begin(SDA_1 , SCL_1 , I2C_Freq );

                                        ^

In file included from C:\Users\HUA.DELLV-PC\Documents\Arduino\sketch_jun05e\sketch_jun05e.ino:1:

C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3\libraries\Wire\src/Wire.h:79:10: note: candidate: 'bool TwoWire::begin(int, int, uint32_t)'

     bool begin(int sda=-1, int scl=-1, uint32_t frequency=0); // returns true, if successful init of i2c bus

          ^~~~~

C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3\libraries\Wire\src/Wire.h:80:10: note: candidate: 'bool TwoWire::begin(uint8_t, int, int, uint32_t)'

     bool begin(uint8_t slaveAddr, int sda=-1, int scl=-1, uint32_t frequency=0);

          ^~~~~

exit status 1

call of overloaded 'begin(int, int, int)' is ambiguous



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Try,

void setup()
{
  I2C_0.begin( 21 , 22 , I2C_Freq );
  I2C_1.begin( 18 , 19 , I2C_Freq );
}

For an ESP32?

1 Like

Expecting a 32bit unsigned parameter.

Try

#define I2C_Freq 100000UL
1 Like

Thanks, yes.

Great!
works.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.