-->
Page 1 of 3

Esp8266 Multiple i2c buses with wire or other soft i2c

PostPosted: Wed Jul 20, 2016 9:04 am
by Ken Shaw
So, as I have found out, the esp8266 i2c solution is purely software, so how am I supposed to enable multiple i2c buses on the esp8266? I tried this like an arduino due would enable with:
Code: Select allvoid setup() {
  Wire.begin(3,4); // join i2c bus (address optional for master)
  Wire1.begin(1,2);
  }
to no success......I've also tried this
Code: Select allvoid setup() {
  Wire.begin(3,4); // join i2c bus (address optional for master)
  Wire.begin(1,2);
  }
but that shouldn't work right? How would I address each i2c bus? Is there another software i2c library which would work for this? (using arduino ide)

Thanks in advance for the help, I've been googling around for forever and I can't find how to do this..... :(

Re: Esp8266 Multiple i2c buses with wire or other soft i2c

PostPosted: Wed Jul 20, 2016 9:31 am
by martinayotte
Wire is a global object already define in Wire.cpp.
To get a second one, you need to instantiate it your self globally in your sketch.
Code: Select allTwoWire Wire2 = TwoWire();

Re: Esp8266 Multiple i2c buses with wire or other soft i2c

PostPosted: Wed Jul 20, 2016 9:37 am
by Ken Shaw
martinayotte wrote:Wire is a global object already define in Wire.cpp.
To get a second one, you need to instantiate it your self globally in your sketch.
Code: Select allTwoWire Wire2 = TwoWire();

Ahh ok, thank you so much :)

Re: Esp8266 Multiple i2c buses with wire or other soft i2c

PostPosted: Mon Jan 23, 2017 4:13 pm
by Joaquin
Hello.

I define in global (sketch)
<Wire.h>
TwoWire Wire2 = TwoWire();

On setup..
Wire.begin(4,5);
Wire2.begin(12,13);

But Both wire and wire2 call wire2. (pins 12,13)

I have updated the library for esp8266 (Arduino) in which it enables global instances
The result is that both wire and wire2 call the last one defined (Wire2) :(

Can you help me ? what am I doing wrong?