Change I2C address OLED

Hi,
I have 2 OLEDs I want to connect to arduino using I2C. They are the same, and I don't see any obvious way to change the I2C address (but I'm no expert). Any ideas?

It's these;

1 Like

Your link shows a different pcb to the one in your photo.

Your photo has an unmounted R5. I suspect that this is for 3.3V operation i.e. to bypass the AMS1117-3.3 regulator.

There is no obvious way to access the address pin.

If you want two 128x32 pictures, I would buy a 128x64 display. And render both pictures on the same screen.

I have the 128x32 pcb shown in your link. There is no way to alter the Slave Address on that pcb.

Incidentally, these OLEDs take very little current. They will "work" with 3.3V on the VCC pin without bothering to bypass the regulator.

David.

1 Like

Hi,

I didn't find the exact one on amazon, it has been removed, but those are almost the same (perhaps should have written that...).
I don' want 1 big screen, I want 2 screens displaying different kinds of data and physically located at different locations.

What about implementing an AND gate (or other similar logic) to select the specific display using additional pins? Turning it in a "chip select"

1 Like

Yes, you can do that. But it would be much easier with two slaves: 0x3C and 0x3D.

You could dismantle one 128x32. Access the ribbon connections.

Or buy one 128x64. Change to 0x3D. Use 0x3C 128x32 in one location. And 128x64 in the other location.

David.

1 Like

Unfortunately, using one that's 64 lines high would make my final product too big.

Alternatively, there might be another way to solve it by looking at the big picture. I want to connect 2 arduinos and have the 2 OLEDs to display information from each one respectively. My initial idea was to connect the 2 arduinos and the 2 OLEDs using I2C (can't use SPI because I need the pins for the peripherals, but I might have 1-2 pis to spare on each board). Any ideas from that perspective?

1 Like

Which Arduino board do you have ?

I think that two OLEDs on a single Arduino Nano is not possible.

The u8g2 library has a software I2C for any pin. It depends on your Arduino board and the mode the library is in and which library you choose if it will work. Some choose the older u8glib library for an Arduino Uno or the U8x8.

Do you have two Arduino boards ? Do you want to communicate via I2C with them ? Then you better provide a lot of information and photos, schematics, and both sketches, because too many of such projects stumble over the I2C bus and fail.

Yes, U8g2 can bit-bash SW I2C on one of the displays.
However Adafruit_SSD1306 only supports HW I2C.

1 Like

It sounds like your whole design may have gone wrong already!

Unless the two Arduino are going to be a long way apart and connected by long serial lines, RF transmitters/receivers etc, using two Arduino is often a bad idea, especially if the reason is to get more pins. It seems to a beginner to make things simpler, but in practice it makes them harder.

You do realise SPI is also a bus, somewhat like i²c, and able to connect to multiple devices?

I think you should tell us about your project, all the components and how you want them to function. You may be right, and 2 Arduino is the way to go, or... better to find out sooner rather than later.

A split keyboard (something like this: https://preview.redd.it/10v5xbppfwg21.jpg?auto=webp&s=586a1bbe23fe5ea910c8bc9ff1db503fbd1644d1)
Each side will have multiple rotary encoders, an OLED display and one of them will have a joystick.

I have 2 Adafruit Itsy Bitsies, and they will be connected through a USB C cable.

I'm still in the prototyping stage, but everything for a single side of the keyboard, I have pretty much tested now, so my next step is to do some prototyping of communication between the 2 sides.

Adafruit Itsy Bitsy, the idea is to use USB C and use data- and data+ for the scl and sca pins.
There will be 1 board and 1 OLED on each side of the cable.

I can provide some schematic/pictures in a little while.

I tried my best showing it on paper, hope this is useful.
In reality, I have some breadboards in between, but I thought this is more descriptive than a picture with all the cables.

Thank you, it is very useful. It is also a very cool project :sunglasses:
The boards are 5V "Leonardo"-alike boards ?

Each board controlling its own OLED is best, but don't connect both via the I2C bus. It will go wrong in many ways.
They both have a spare Serial port. Use that. You have to find/make a protocol to communicate.

What will go wrong with I2C ?

  • The I2C bus between Arduino boards (and compatibles) is a bad idea anyway.
  • You will have two Masters on the I2C bus (because each board is a Master for its own OLED). A multi-master I2C bus with Arduino boards is a fairy tale.
  • Is that a 5V board ? The OLED uses 3.3V signals for SDA and SCL. The communication with the other board and other sensors might not work because of the OLED. That means your I2C bus is pretty bad.
  • The SDA signal should not be next to a SCL signal. Since your I2C bus is pretty bad, the cable might be just too much.
  • The Master waits until a I2C session has completely finished. There is no waiting with Serial communication.

Do both parts have to communicate with each other ? Is it perhaps possible to connect both via USB to the computer ? The computer will see two keyboards. I think my split keyboard does that.

As mentioned, I'm still trying to figure some things out as I'm prototyping. I haven't done anything with I2C before, so I'm basing my tests from what I've seen so far.

  • You will have two Masters on the I2C bus (because each board is a Master for its own OLED). A multi-master I2C bus with Arduino boards is a fairy tale.

Wouldn't one of them be a master and another slave? But I was wondering if that's the case, if the slave one would be running a lot slower than the master (at the clock speed of the SCK bit of the master)?

  • Is that a 5V board ? The OLED uses 3.3V signals for SDA and SCL. The communication with the other board and other sensors might not work because of the OLED. That means your I2C bus is pretty bad.

It is a 5V board at 16Mhz (see the 3677 model here Pinouts | Introducing ItsyBitsy 32u4 | Adafruit Learning System).
For now, I haven't anything else planned to use the I2C bus. The other pins will be used for rotary encoders, a joystick, the keyboard matrix rows/columns, possibly backlighting (TBD).
The OLED uses 5V? (see this image for another variant of the same OLED by the same manufacturer https://m.media-amazon.com/images/I/61waQGxM-wL.AC_SX679_.jpg)

Do both parts have to communicate with each other ? Is it perhaps possible to connect both via USB to the computer ?

I'm sure it's possible, but I don't want it that way. I sometimes connect my PC to the TV and sit further away from it. Having it that way would require extra extension cords and/or hubs. I also want to use it with my laptop, which only has 1 free USB, having 2 would also require a hub, which I'm not too keen about. But it would have been easier, yes.

They both have a spare Serial port

Do you mean SPI or something else?

  • The SDA signal should not be next to a SCL signal. Since your I2C bus is pretty bad, the cable might be just too much.

Can you elaborate?

  • The Master waits until a I2C session has completely finished. There is no waiting with Serial communication.

Do you mean the I2C communication will cause the other processing logic to be on pause until that communication has completed? Meaning the OLED display logic would potentially cause the key events not be processed on time?

The Leonardo/ATmega32U4/ItsySomething has a spare hardware Serial/UART port.
You can use that to communicate with RX and TX. In the Arduino-world it is often called a "Serial" port, although most buses use serial communication :wink:

The OLED has a 3.3V I2C bus. That is one of the reasons that OLED disturbs the I2C bus for others.
Any clown :clown_face: can sell OLED displays and claiming they are also for 5V. Only Adafruit makes their OLED displays compatible with a 5V I2C bus.
When you buy something at Amazon/Ebay/Aliexpress, expect a lot of rubbish

If you make one board the Master for two OLEDs plus the other board as a Slave as well, then you need to run two OLEDs in a single basic Arduino (compatible) board. I think there is not enough memory for that. You would also need to put the I2C bus in a cable, which is not good with a I2C bus that is already pretty bad.

Did you know that the I2C bus was not designed to go into a cable ?

Yes, but only for the Master. You won't notice it with a single sensor, but with a lot of communication between boards or with many sensors, the sketch starts to slow down.

A I2C bus with a slow clock has no influence on what the Slave can do. The Slave receives the bits with hardware. The Slave does not have to wait for something.

O no, you really asked me to elaborate on the I2C bus :scream: May I point to my my Wiki at Github ? see also the other pages of that Wiki.

Interesting high speed OLED updates: https://www.youtube.com/watch?v=sFGsYZ0Hszk (SPI bus, but the Wokwi simulation has only the OLED with I2C bus and it is also fast).

I will investigate

Interesting. I connected it as it was described on amazon and it worked, didn't think much more of it. Should I change it to 3.3V instead?

&

No. Sorry, I will do some more research. I searched for communication between 2 arduinos, I2C and SPI is what I found. Decided to use I2C as it uses less pins and I need those for other things. Looked at some tutorials and did some prototyping, didn't expect to run into other issues, all this is still quite new to me. My bad. I will look into both links and do some additional research.

I did not read all of the above. But to address (pun intended, ha ha) your original question, then consider something like this:

74HCT245 tri-state octal bus transceiver Datasheet (futurlec.com)

Thanks, but another poster pointed out that using I2C as I intended (over a cable), is not recommended. If I use serial communication between my 2 arduinos, I can use I2C between 1 OLED and 1 arduino board respectively (within the same board only), thus eliminating the problem altogether.

Thanks, but it seems that the best way to approach my problem is to split the usage of my OLEDs to the 2 arduino boards instead, and have them communicate by some other protocol that can be used in a cable, like serial communication.