OLED SSD1306 I2C Address

For general Flowcode discussion that does not belong in the other sections.
gregobac
Posts: 9
http://meble-kuchenne.info.pl
Joined: Fri Sep 10, 2021 8:59 am
Been thanked: 1 time

OLED SSD1306 I2C Address

Post 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 ?

BenR
Matrix Staff
Posts: 1706
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: OLED SSD1306 I2C Address

Post 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.

gregobac
Posts: 9
Joined: Fri Sep 10, 2021 8:59 am
Been thanked: 1 time

Re: OLED SSD1306 I2C Address

Post 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.
Attachments
OLED1306.fcfx
(10.78 KiB) Downloaded 145 times

medelec35
Matrix Staff
Posts: 1429
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 505 times
Been thanked: 468 times

Re: OLED SSD1306 I2C Address

Post 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 4149 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?
Martin

BenR
Matrix Staff
Posts: 1706
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: OLED SSD1306 I2C Address

Post 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.

gregobac
Posts: 9
Joined: Fri Sep 10, 2021 8:59 am
Been thanked: 1 time

Re: OLED SSD1306 I2C Address

Post 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

medelec35
Matrix Staff
Posts: 1429
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 505 times
Been thanked: 468 times

Re: OLED SSD1306 I2C Address

Post 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.
Martin

gregobac
Posts: 9
Joined: Fri Sep 10, 2021 8:59 am
Been thanked: 1 time

Re: OLED SSD1306 I2C Address

Post 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

medelec35
Matrix Staff
Posts: 1429
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 505 times
Been thanked: 468 times

Re: OLED SSD1306 I2C Address

Post 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.
Martin

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: OLED SSD1306 I2C Address

Post 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 4107 times

Post Reply