Post topics, source code that relate to the Arduino Platform

User avatar
By s100
#95485 I have a commercial PCB with an ESP 12-F, PCF8563 Clock, and SSD1306 based OLED. The PCF & SSD1306 are on two different IC2 busses for some stupid reason. Details:

PCF is SDA=0, SCL=2, Address 0x51
1306 is SDA=5, SCL=4. Address 03C

I can communicate fine with one or the other using Wire.begin(0,2) or Wire.begin(5,4), but have not been able to talk to both in the same sketch.

I tried using "Wire.end();" since that is supposed to "Disable the Wire library, reversing the effect of Wire.begin(). To use the Wire library again after this, call Wire.begin() again." Sounds perfect., but ........

When I use it, I get a compiler error that "class TwoWire has no member named 'end'". Looking at Wire.h and Wire.cpp files, they both include the end() function. So ?????

1. Any suggestions about this error? The Wire.h file has a note that it was modified in 2020, so it is fairly recent.

2. Alternative ideas? An I2C multiplexer probably isn't in the cards. If there is no software solution I will use a knife and soldering iron to put both devices on the same bus.
User avatar
By s100
#95528 Yes. I am using a pre-made commercial board and they have the two slaves on different I2C busses. Why? I don't know. But I have seen several similar products that do the same thing.

On one board I used a knife and soldering iron to connect both slaves on the same bus and it works. But this requires having to physically hack up each board and have jumper wires soldered to delicate IC pins. While it can be done, a software solution is more elegant and preferred.

I have found one new piece of information. I have two copies of the Wire library on my computer. One is for the "avr" architecture and includes the Wire.end() function, and the second is for the "esp8266" architecture and doesn't include the Wire.end() function.

Investigation continues.
User avatar
By s100
#95544 I have found two solutions, one hardware and one software. Both of these work for me.

Hardware: Cut the traces to the SDA and SCL on one sensor and jumper it to the other bus. In my case I put the RTC on the same bus as the OLED.

Software: Wire can be switched from one bus to another using the Wire.begin(SDA,SCL) function. In my case the OLED is on IO5 and IO4 and the pcf8563 RTC on IO0 and IO2. When I need to talk to one or the other I issue:
Code: Select allWire.begin(5,4);   //for the OLED
Wire.begin(0,2);  //for the RTC


Another option may be to use a multi bus library like Multi_BitBang, or any second library for the 2nd bus. Using any none Wire library may cause issues with other libraries like Rtc_Pcr8563 as they explicitly expect Wire.

Trying to have two instantiations of Wire doesn't work.