changing I2C addresses
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

changing I2C addresses

by bob21 on Fri Apr 30, 2021 6:51 pm

I have a SSD1306 running with Adafruit's SSD1306 and GFX libraries
I am wondering if it is possible from within the sketch to alter the I2C address so i can run two displays.
In Adafruit_SSD1306.h there is a line uint8_t i2caddr = 0; I have played with this and it seems to make no difference what number I put after the equals sign if I add it into the sketch either above the void setup(); or in it.
The sketch I am using is one of the adafruit sketches, ssd1306_128x32_i2c.
one line in it says display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
If I change it from 0x3C I lose the output to the display but I can't get it to work on another address..
The 41st reply in the thread here
shows how to do it but this is not using the adafruit library so I assume it can be done?
Any help would be appreciated.

Posts: 4
Joined: Sat Sep 29, 2018 7:13 pm

Re: changing I2C addresses

by dastels on Fri Apr 30, 2021 8:28 pm

What display board do you have?

The I2C address is determined by a pin on the chip. Connecting it to ground or Vcc selects one of two possible addresses. This pin is often wired to a jumper that you can connect/disconnect to set the address. E.g. the A0 jumper on https://learn.adafruit.com/assets/86658. In the begin call you pass the appropriate address. If you have two displays, set the jumper differently on each on each board. In the code, create two display object and use the corresponding address in each begin call.


Posts: 6513
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.