Page 1 of 4

OLED SSD1306 I2C Address

Posted: Wed Sep 29, 2021 2:45 pm
by gregobac
Hello,

On the OLED Display SSD1306, on the I2c address, we can only select 0x78 or 0x7A
Image

In my case the I2C address is 0x3C.
Confirmed with an I2C scanner and with this example : https://www.instructables.com/Monochrom ... ino-SSD13/

How can we change the address ?

Re: OLED SSD1306 I2C Address

Posted: Wed Sep 29, 2021 3:15 pm
by BenR
Hello,

Address 0x3C = 0x78

0x3C is a 7-bit address and 0x78 is the 8-bit address but they are the same.

To get the display working ensure you have pull up resistors to VCC on the SDA and SCL lines. 1K to 10K should work well.

Re: OLED SSD1306 I2C Address

Posted: Wed Sep 29, 2021 4:56 pm
by gregobac
Hello Ben,

I didn't find any example about SSD1306-I2C in FC9 with ESP32.

This program in IDE Arduino works perfectly :

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
Serial.begin(9600);
Wire.setClock(400000);
Wire.begin();

// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed")); }
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.cp437(true); // Use full 256 char 'Code Page 437' font

display.clearDisplay();
display.setCursor(0,0);
display.println(F("Status:Free"));
display.display();
}
void loop() {
}

My OLED1306.fcfx example program don't work.
Maybe the I2C pins assignment.

Thank you for your help.

Re: OLED SSD1306 I2C Address

Posted: Thu Sep 30, 2021 9:18 am
by medelec35
I'm using a wifi kit32 which has a SSD1306.
I can confirm your flowchart working for my display using 0x78.
SSD1306.jpg
SSD1306.jpg (12.24 KiB) Viewed 4292 times
The only things I changed was the pins as my display is built in to the ESP32.
The Baud Select from 100k to 400k as 100k is way too slow.
Interlaced to yes otherwise will cause the display to look wrong.
The font to Calibri 14 since interlaced will make the default font fairly small.

Have you tried a 1 second flash test?

Re: OLED SSD1306 I2C Address

Posted: Thu Sep 30, 2021 9:57 am
by BenR
Also you didn't comment about the hardware pull up resistors on the SCL/SDA pins?

You can enable software pullups if required and this is probably what the Arduino code is doing.

Re: OLED SSD1306 I2C Address

Posted: Thu Sep 30, 2021 12:56 pm
by gregobac
I just made this wiring :
Image
i have to find how enable the internal pull up...

it would be interesting if the initialization routines could return an information if everything went well

Re: OLED SSD1306 I2C Address

Posted: Thu Sep 30, 2021 1:23 pm
by medelec35
My recommendation is not to use internal weak pull-up resistors.
As there are around 45K it could cause timing issues.
Hardware will not work as well as if you use the values Ben has stated.

Re: OLED SSD1306 I2C Address

Posted: Fri Oct 01, 2021 9:58 am
by gregobac
My OLED Adafruit own pull-up resistors. I wired an oscilloscope on the I2C signals. No activity on the SDA and SCL. The signals are 3.3V level.

I monitor the COM port and the see a problem on the DEBUG info :

[0;31mE (373) i2c: i2c_param_config(647): i2c clock choice is invalid, please check flag and frequency[0m
[0;31mE (383) i2c: i2c_master_cmd_begin(1166): i2c driver not installed[0m
[0;31mE (383) i2c: i2c_master_cmd_begin(1166): i2c driver not installed[0m
[0;31mE (383) i2c: i2c_master_cmd_begin(1166): i2c driver not installed[0m
......

I tried to change frequency ( 100K , 400K or 1M ) , the problem was the same.
I updated the library and recompile the program. The problem was the same.

I also try to create a simple program to send a message on I2C, the problem is the same.
No activity on the SDA and SCL

Re: OLED SSD1306 I2C Address

Posted: Fri Oct 01, 2021 10:23 am
by medelec35
Did you try the one second flash I suggested in a previous post?
It's best to confirm hardware working before stating any project.

Re: OLED SSD1306 I2C Address

Posted: Fri Oct 01, 2021 10:40 am
by stefan.erni
Hi gregobac


Can you for the test with the oscilloscope print nonstop "test"?

It's more comfortable
and you can also trie to set the I2C to software mode?

regards

Stefan
print_2021-10-01_11-34-53.png
print_2021-10-01_11-34-53.png (33.84 KiB) Viewed 4250 times