Hello,
I'm working on a project which requires three SH1106 OLED Display. Because they have the same address, I need to use three I2C buses, and I would like to avoid adding more hardware to my project. I found that the lcdgfx library by lexus2k allows users to select SDA and SCL pins when a display object is created.
In order to test it, I simply modified one line of the SH1106 demo, which is provided with the library, to wire the display on other pins that the two default I2C pins on Arduino. Here is the line I changed : DisplaySH1106_128x64_I2C display(-1, {-1, 0x3C, 12, 13, 0});
With this code, the screen remains black. I think it has something to do with the busId parameter, but I don't know which value should be given since I work on Arduino. Here is the docs.
Does anyone have already used this library in a similar way ?
Hello,
I'm trying to use three SH1106 Oled Displays simultaneously, with different information on each display.
I've done some research and it appears that it's impossible to change the address of those displays. I would prefer to avoid using an I2C mux if a software solution is possible.
I'm using the Adafruit_SH110X library to control the displays (one by one), because I need to be able to draw shapes, not only strings. I tried many Software I2C libraries, but I can't create three different display objects associated to three different pairs of pins on the Arduino. I nearly always have an error when I'm calling the constructor of an Adafruit_SH1106G object : it requires a &Wire argument while I can only provide TwoWire, Softwire or any other object associated with the software I2C library that I try to use.
I thought about modifying existing libraries, but I don't have enough knowledge to be sure that it would work (and I also am not sure what to change exactly).
So, do you know any way to control three I2C displays that have the same address at the same time ?
IMO you'll need a library that supports multiple display objects and can switch between multiple displays on one or different bus systems. Looks quite exotic to me
Use a software i²c library to create 2x extra i²c objects so you have 3x i²c objects in total, each using a different pair of pins. When creating the display objects, give each object one of the i²c objects.
There are drawbacks to this approach. Software i²c is slower than hardware, so those displays may update pretty slowly. Also with 3 display objects and 2 software i²c objects, you may run short of ram memory on Arduino based on atmega328 or similar.
I've been researching software i²c libraries and I'm coming to the conclusion that they are not going to work like we hoped.
The problem, I think, is the class structure. If "TwoWire" and "SoftWire" classes shared a common base class, and the Adafruit_SH1106G constructor would accept any object derived from that base class, it would work. But this just wasn't thought about when the classes were defined, I suspect.
So I think you may have to look at a hardware option.
One is the i²c multiplexer idea that you wanted to avoid.
Another is to choose an Arduino board with 3 i²c hardware ports. I think that, with some configuration of its SERCOM ports, an Arduino Zero compatible board based on SAMD21 chip might work.
Thanks for your answers. Using a I2C multiplexer would be the simplest option, but I've already done the CAD for my project and it would cost a bit more so I'm exploring all the software options.
I'm currently trying to use the lcdgfx library by lexus2k (GitHub - lexus2k/lcdgfx: Driver for LCD displays running on Arduino/Avr/ESP32/Linux (including Rasperry) platforms), which apparently allows the creation of a display object with custom SDA and SCL pins. I can't make it work for now, but I will create a new subject on the forum for that.