Chat here is you are connecting ESP-xx type modules to existing AVR based Arduino

Moderator: igrr

User avatar
By Stoney
#21303
AcmeUK wrote:Like Mario says, before using I2C, pins for SDA and SCL need to be set by calling Wire.begin(int sda, int scl). See I2C section here :- https://github.com/esp8266/Arduino


Mario must have mods, I was attempting to get an I2C LCD up and running last night and ran into the same issues, there is no wire.begin that takes 2 initialisers.
I had just installed v1.65 though, thought I broke something but looking on github, the esp8266 wire routines are also identical to the standard arduino library versions and have not changed for a year.

the post above makes sense, will try that shortly.
User avatar
By Stoney
#21320
tytower wrote:From https://github.com/esp8266/Arduino
I2C (Wire library)

Wire library currently supports master mode up to approximately 450KHz. Before using I2C, pins for SDA and SCL need to be set by calling Wire.begin(int sda, int scl), i.e. Wire.begin(0, 2); on ESP-01, else they default to pins 4(SDA) and 5(SCL).



..and have you actually bothered to try it ?

this is the result of adafruits ssd1306_128x32_i2c demo if I use
Wire.begin(0,2);


ssd1306_128x32_i2c.ino: In function 'void setup()':
ssd1306_128x32_i2c:64: error: no matching function for call to 'TwoWire::begin(int, int)'
ssd1306_128x32_i2c.ino:64:17: note: candidates are:
In file included from ssd1306_128x32_i2c.ino:20:0:
C:\Users\Col\Documents\Arduino\hardware\esp8266com\esp8266\libraries\Wire/Wire.h:53:10: note: void TwoWire::begin()
void begin();
^
C:\Users\Col\Documents\Arduino\hardware\esp8266com\esp8266\libraries\Wire/Wire.h:53:10: note: candidate expects 0 arguments, 2 provided
C:\Users\Col\Documents\Arduino\hardware\esp8266com\esp8266\libraries\Wire/Wire.h:54:10: note: void TwoWire::begin(uint8_t)
void begin(uint8_t);
^
C:\Users\Col\Documents\Arduino\hardware\esp8266com\esp8266\libraries\Wire/Wire.h:54:10: note: candidate expects 1 argument, 2 provided
C:\Users\Col\Documents\Arduino\hardware\esp8266com\esp8266\libraries\Wire/Wire.h:55:10: note: void TwoWire::begin(int)
void begin(int);
^
C:\Users\Col\Documents\Arduino\hardware\esp8266com\esp8266\libraries\Wire/Wire.h:55:10: note: candidate expects 1 argument, 2 provided
Multiple libraries were found for "Adafruit_GFX.h"
Used: C:\Users\Col\Documents\Arduino\libraries\Adafruit_GFX
Not used: C:\Users\Col\Documents\Arduino\libraries\AndroLociciels_GFX
no matching function for call to 'TwoWire::begin(int, int)'


I bolded the bottom line ..

however ..

I put Wire.pins(0,2);
in the code.. and the same code ...

Sketch uses 212,372 bytes (40%) of program storage space. Maximum is 524,288 bytes.


not only that .. but my i2c oled display conneted to gpio 0 and 2 on an esp01 .. works.
though not for long .. the watchdog cuts in drawing lines, just added some yield() to the line drawing routines but now my esp01 has bricked itself and is refusing to load an image..