Notifications
Clear all

SSD1306 OLED Issues with ESP32

35 Posts
4 Users
0 Likes
3,166 Views
(@fishbone)
Member
Joined: 1 year ago
Posts: 54
Topic starter  

 

Hi. I'm running Windows 10 with PlatformIO and tried this simple "Hello World"

#include <Arduino.h>
/*********
  Rui Santos
  Complete project details at  https://randomnerdtutorials.com   
*********/

#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)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin(115200);

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000);
  display.clearDisplay();

  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 10);
  // Display static text
  display.println("Hello, world!");
  display.display(); 
}

void loop() {
  
}

 

I get this:

20230212 124431

 

I tried a second display and the outcome was the same. I also tried the second I2C connection (the board has 2) and also got the same thing. Any help is appreciated!

Mark


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6964
 

Posted by: @fishbone

 

Hi. I'm running Windows 10 with PlatformIO and tried this simple "Hello World"

#include <Arduino.h>
/*********
  Rui Santos
  Complete project details at  https://randomnerdtutorials.com   
*********/

#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)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin(115200);

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000);
  display.clearDisplay();

  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 10);
  // Display static text
  display.println("Hello, world!");
  display.display(); 
}

void loop() {
  
}

 

I get this:

-- attachment is not available --

 

I tried a second display and the outcome was the same. I also tried the second I2C connection (the board has 2) and also got the same thing. Any help is appreciated!

Mark

Is that sketch one of the samples? Is it unchanged?

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 

@fishbone

Just from your picture, it appears that your wiring is incorrect. Maybe it's just the camera angle but it appears that you have the white wires going to the SDA and SCL on the display but coming from SCL and TX on the ESP.

Also, check that your display is suitable for 3.3V supply (or does it need 5V?).

Also, your sketch has a comment that says 0x3D is the address for your display but your display.begin specifies address 0x3C ?

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@fishbone)
Member
Joined: 1 year ago
Posts: 54
Topic starter  

@will That is just the angle of the photo...the wiring is correct.  I tried using a 5V supply and it did the same thing.  The correct address is 0x3C - the comment was because this is an example sketch.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 

@fishbone 

Then I'm out of ideas, hope you get it working.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@fishbone)
Member
Joined: 1 year ago
Posts: 54
Topic starter  

@will thanks...me too


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 

@fishbone 

I downloaded the library and checked an example sketch and it has the line ...

#define SCREEN_ADDRESS 0x3D ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32

Your setup specified 128x\64 but you're using the screen address for a 128x32. That could mess up the display because the pixel addresses would be calculated incorrectly.

Please try using 0x3D as the address and see if that works. Otherwise use 0x3C as the address but change the resolution to 128x32.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6964
 

@fishbone Try another sample sketch from the AdaFruit library, but maybe also try some more generic OLED display samples. The wiring is simple and you seem to have done it correctly. If that doesn't work, use a different esp32, perhaps a full-size board. Also, try with a dedicated 5V supply to the display.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@fishbone)
Member
Joined: 1 year ago
Posts: 54
Topic starter  

@zander Hey, I tried a different board.  This is a Wemos Lolin EMC320C3 PICO...it looks like the previous board but that was an Adafruit.  You can see the results are the same.  Oh, that pic also has a RTC module, but I removed it and it isn't having an effect.  I also tried driving it with 5V....no luck.

On another note...this board is not exhibiting the COM port issue the other board had.

20230212 152638

 


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@fishbone 

Do you have a pinout for that board?
I couldn't find it at,
https://randomnerdtutorials.com
Where exactly is the project you are trying to duplicate?

This was the only board type I could find.

https://lastminuteengineers.com/oled-display-esp32-tutorial/

 


   
ReplyQuote
(@fishbone)
Member
Joined: 1 year ago
Posts: 54
Topic starter  

@robotbuilder This is the pinout for the board.  https://www.wemos.cc/en/latest/c3/c3_pico.html

 

The tutorial is here:

https://randomnerdtutorials.com/guide-for-oled-display-with-arduino/


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6964
 

@fishbone If you apply 5V to a 3.3V device you will kill it. Do NOT do that. Figure out the correct voltage and if any doubt use 3.3V first.

Did you correct the I2C address as @will pointed out?

Did you try a sample sketch?

Random Nerds are very good, but they have been known to make mistakes as well.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6964
 

@fishbone READ the address must be 3D as it says in the comment for 128x64, the code appears to be wrong.

 

Screenshot 2023 02 12 at 14.55.59
Screenshot 2023 02 12 at 14.56.08

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@fishbone)
Member
Joined: 1 year ago
Posts: 54
Topic starter  

@zander that is incorrect.  I ran the I2C address scanner.  My address is 0x3C.  I also compiled and uploaded with 0x3D just to check and when I do so the screen is blank.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 

@fishbone 

Then change your screen size #define to 32 from 64.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Page 1 / 3