I am taking the course “Learn ESP32 with Arduino IDE”.
I am at my wits end trying to get the simple “Hello World” program to work.
The first thing people suspect is wrong is either wrong wiring of the ESP32 to the OLED display OR the wrong address specified for the OLED.
Neither of these are the problem and the I2C_scanner returns an address of ox3C for the OLED.
What is very interesting is this: When I run the Adafruit sketch for the SD1306 based OLED module, I can see that the code is running as it should AND the OLED actually display SOME of the output.
What I see is this: ONLY the top few lines of pixels (approx. 2 mm of the entire 15 mm display area) shows the output!
The remainder of the display appears to contain random bits; i.e. most of the pixels are on.
If I change the screen height to 32, then I get approx. 4 mm of the 15 mm screen with output — go figure!
The display behaves in a similar manner when I run Rui’s “Hello, World” program.
EITHER the OLED module is faulty OR I’m being told wrong info by my source of instruction.
Problem is — I have no way to be sure which it is since I only have one OLED modules.
However, I just recently solved that problem by buying 5 modules from 2 different sources.
If none of my new modules work, my only recourse is to abandon all instruction EXCEPT that which comes from Adafruit Industries in New York City — I have never had a problem with Adafruit in the 5 years I’ve been dealing with them.
I hate to make assumptions but is this the board you have? You need both the Adafruit libs to make it work – SSD1306 and GFX Library. Pretty sure it’s a 128×64 display so you’ll need to uncomment the define for that (define SSD1306_128_64) and comment out the rest in the Adafruit_SSD1306.h file. In your code (Even the example code) you’ll need to set the IIC address when you begin – display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
If that doesn’t work, try the u8g2 library.
If neither work then I would start looking at the module itself.
YES, it is the same board. I did uncomment the #define for 128×64 and commented out the other 2.
Here is the sketch: I took a photo of the OLED display but don’t know how to pass it along. I’m reluctant to use anything not mentioned in the course (i.e. the u8g2 lib) — I may have been wrong to take this course — I’m glad I didn’t sign up for any more yet! After all, what is given in the course should work! I’ll wait until I receive my new OLED displays before I declare this one bad. I have some of the same coming from another source AND I have one from Adafruit coming tomorrow (its not the same display, but Adafruit stuff is always good and they support it.)
Thanks for your help.
Ray
#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);
while(!Serial);
Serial.println(” “);
Serial.println(“HELLO, WORLD!”);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128×64
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() {
}
———————–
Hi Ray.
I’m sorry for your issue.
I’ve just tried that example now, and it is working fine for me. So, the instructions are working as expected.
What you described seems to be an issue with the display itself.
Can you post a link to where you bought your display? Are you sure it is an OLED display with the SSD1306 driver? There are similar displays with a different driver that won’t work with this example.
If you could test the examples with a new display, that would be better.
To share an image, you can share a link to google drive, imgur or another place that can host your image.
Regards,
Sara
Sara;
Thank you for your help. Here is the URL for my OLED purchase:
https://www.banggood.com/Geekcreit-0_96-Inch-OLED-I2C-IIC-Communication-Display-128+64-LCD-Module-Geekcreit-for-Arduino-products-that-work-with-official-Arduino-boards-p-1535708.html?rmmds=myorder&cur_warehouse=USA&ID=229
It appears to be an SSD1306 based display. It is beginning to look like I was the unfortunate recipient of one of those faulty units that got passed the QA process — it happens!
At this point, I’m going to start the “return process” with Banggood.
I will shortly receive one of these: Monochrome 0.96 128×64 OLED Graphic Display – STEMMA QT : ID 326 : $17.50 : Adafruit Industries, Unique & fun DIY electronics and kits
I think it will work — what do you think?
I also ordered this: Amazon.com: PEMENOL 5PCS OLED Display Module for Arduino, 0.96 Inch I2C IIC Serial 128 x 64 OLED LCD Display Module with SSD1306 Driver for Raspberry Pi and ESP8266 – White Light : Industrial & Scientific
Again — does it look like it will work?
Sara, your help has convinced me to continue my education with RNT — thanks;
Ray
Hi.
The Banggood link you shared is an SSD1306. I have some of them and they work well. So, you must have received a faulty display.
That adafruit display works with the SSD1306 library, so it should also work.
The other displays from amazon also seem to be compatible.
Once you’ve received those displays, let me know if you got them working.
Regards,
Sara
Sara;
Success!
Today I took delivery from Adafruit for the Mono 0.96 inch 128×64 OLED Display (STEMMA QT).
This unit has the 2 tiny connectors on either side of the board (I believe they are called STEMMA QT). The URL is: https://www.adafruit.com/product/326
The I2C_scanner shows the I2C address as 0x3D — NOT 0x3C as the Geekcreit board shows!
The Adafruit library sketch “ssd1306_128x64_i2c” from the Arduino IDE works perfectly!
I have already submitted a “return request” to Banggood for a replacement part.
Since the part only costs me $12, I’ll just ignore the return request if I incur a cost near the $12.
Unfortunately for Banggood, this return request may be the end of anymore business I do with them.
Thank you, Sara, so much for your help.
I am encouraged to continue my studies with RNT.
Soon, I’ll be taking delivery of the remaining parts I need for the Learn ESP32 course.
I can’t believe I’m still at it after all the years: I started Electronics in 1962 and programming in 1968 (curtesy of the U.S. Air Force and the U.S. Navy, respectively)
Ray
I’m glad everything is working as expected now.
I hope you solve your return with Banggood.
I never had any problems with them.
I hope you enjoy learning ESP32. I guess it’s easier to program nowadays than back in 1968.
I’ll mark this issue as resolved.
If you need further help, you just need to open a new question in our forum.
Regards,
Sara
I thought it would be good if I made this FINAL comment on the difficulties I had in try to use the OLED display in the “Learn ESP32 with Arduino” course I am taking.
As you will se from the various exchanges above, I had a fair amount of trouble getting things to work.
It is now Nov 13 and today I was finally able to convince myself of exactly what the problem was. In some ways, the problem was ME!
When I took delivery of my parts from Bangggod.com, I was so enthused to get moving on the course, I did not do what we should all do when receiving goods from people like Banggood. If I had checked what they sent me before I tried to use it, I may not have had the troubles I had.
Instead of a 0.96 inch OLED based on the SSD1306 driver chip, they sent me the 1.3 inch OLED based on the SH1106 driver chip. Unfortunately, I know of no way to discover which driver chip an OLED module is using. However, the size difference between 0.96 and 1.3 is certainly meaningful and probably ought to have caught my attention and made me suspicious.
Long story short — it wasn’t until today that I convinced myself of what had happened and I was able to successfully use the OLED I received once I made use of the U8g2 Library. In all fairness, Sara had suggested I try the U8g2 lib, but I was too confused to know where to start. I’m slightly less confused today.
MESSAGE to all who dare to tread upon the OLED display landscape: BEWARE — there are many, many variations of the small OLEDs that are typically used with MCUs.
Hi.
Thanks for sharing that.
The OLED display with the SH1106 drivers won’t work with the examples for the SSD1306.
You can also try this for that OLED display (I haven’t tried it): https://github.com/davidperrenoud/Adafruit_SH1106
I hope you’re able to get it working.
Regards,
Sara
Sara;
I took a look at the code you mentioned from David Perrenoud on Github.
I was a little discouraged right away when I saw it was 6 years old — that is an eternity in this business!
It has an example program “sh1106_128x64_i2c.ino”, but when I tried it I got compile errors about not being able to find the file “Adafruit_SH1106.h”. I wasn’t able to find that header file in the Arduino installation, so I put the entire unzipped file I downloaded from Github into my directory under “libraries” and the compile error went away.
But, I then got this new error:
C:\Users\rayle\Documents\Arduino\libraries\Adafruit_SH1106\Adafruit_SH1106.cpp: In member function ‘virtual void Adafruit_SH1106::drawPixel(int16_t, int16_t, uint16_t)’:
C:\Users\rayle\Documents\Arduino\libraries\Adafruit_SH1106\Adafruit_SH1106.cpp:113:5: error: ‘swap’ was not declared in this scope
swap(x, y);
As you can see, it has something to do with a ‘swap’ function being out of scope.
At this point, I have to give up because this is beyond me! I tried to follow what the readme file says to do in the Github repo but I either failed to do something correctly or too much has changed in the past 6 years and no one is updating things.
I have 3 “kinds” of OLEDs: a 1.3 inch SSH1106 based OLED which I have been able to use with U8glib for text and I have 2 0.96 inch OLEDs (1 from Adafruit with the STEMMA connector) and 1 from some internet source.
I have them all working with either the Adafruit library (the one from Adafruit) or the U8g2 library which replaces the U8glib.
At this point, I’ll just consider the one from Github (https://github.com/davidperrenoud/Adafruit_SH1106) beyond any effort I wish to expend.
Thanks anyway for the suggestion. I’m moving on within Module 4 (Web Servers).