Hi - I have a fairly large sketch on an arduino uno which makes a lot of use of a 1.3” oled display. I find that when I run the sketch as I intend it to be, the oled remains blank, but if I delete half a dozen or so pairs of lines of this kind, the system works perfectly -
This is true even if the deleted calls are not in the direct execution path when the system is powered up - they are in parts of the code accessed by conditional branches. The declarations and setup parts of the sketch include the following statements -
#include <U8x8lib.h> //U8x81lib included to improve initialisation of the 1.3" display
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
U8X8_SH1106_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);
#include <Arduino.h>
#include <Wire.h>
#include "SSD1306AsciiAvrI2c.h"
// OLED Display constants
#define I2C_ADDRESS 0x3C
// OLED - Declaration for a SSD1306 display connected to I2C (SDA, SCL pins)
SSD1306AsciiAvrI2c display;
void setup()
{
// Initiating the OLED Display
Wire.begin();
u8x8.begin(); //this has been included to improve the 1.3" display.
u8x8.setPowerSave(0);
display.begin(&Adafruit128x64, I2C_ADDRESS);
display.setFont(Adafruit5x7);
display.setContrast(255);
display.clear();
You will have to post the entire code in code tags and a wiring diagram as well. Since it's been a while since you were on here, maybe a review of the pinned post re 'How to get the most from the forum'
Also, it's quite strange that if you delete a few lines (what you have shown are commented out lines, but i'm now assuming that that is what you mean when you say "delete").
You seem to initialise the display twice, with 2 different libraries which you tell it's some noname display, and the other one it's an Adafruit display.
That's already confusing to me, i have no idea what the IDE makes of that.
In the mean time, read this thread (click!) for some tips about initialising these displays and see if that will help you out.
Removing lines like this frees program memory. Try using the F() macro on all Serial.print() statements, or find an OLED library that uses less memory.
Hi - I am trying to get a 1.3 inch SSD1306 oled to display a simple text message, but not succeeding. The device is connected with SDA to A4, and SCK to A5. After reset, the display blinks and then displays a white background with random black spots. I interpret this as meaning that the display has not initialised. There is no output on the serial monitor. What am I doing wrong ?
Your code appears correct and will work with many of the Arduinos. I am assuming you are using a UNO, is that correct? Also post a simple schematic showing how you connected this hardware. @david_2018 is asking the same questions.Word salads used as schematics are useless.
Also, run the I2C scanner and let us know what you get.
Hi - I have posted 2 previous questions about using a 1.3" SH1106 OLED, and have received some helpful replies, but I have still not cracked this nut. Here is an outline of the current situation -
This is a large sketch with a large number of text messages written in source code as string literals. These over-fill RAM if left to the compiler to deal with. I have used F() to transfer them to ROM. This solves the RAM overflow problem.
I now have a ROM problem, which I feel is not insoluble, but this involves the driver for the oled. Initially I made a mistake, and assumed that the device was SSD1306-based. I used the Adafruit_SSD1306.h library, and the system worked (!) but the display had an annoying white stripe down the right-hand side. However, the good news was that with the use of F(), both ROM and RAM had healthy margins of capacity. This is why I feel the problem is not insoluble.
If I use the correct Adafruit_SH110X.h library the display works correctly with a smaller sketch, but in the intended project there is grossly too much code for the rom: this driver inflates the compiled code dramatically.
My interpretation of this is that I need to find a driver for the SH1106 OLED which is sparing of memory space. I only need to display alpha-numeric messages; no graphics is involved.
If anyone can point me in the right direction it would be hugely appreciated.
These libraries often keep a full copy of screen data in memory (number of pixels x uint16_t).
Find a library that does not do that..
Maybe you can simply omit using such a buffer with your current library...
For this, I have used ss_oled by Larry Banks. No extensive experience, but it did do what I needed, and was parsimonious wrt RAM. It only incorporates the fonts you reference, IIRC, so keep to one font size and it's even better.
U8g2 has an option for a paged display buffer, which is much smaller than the full buffer needed by the Adafruit libraries. It also includes the U8x8 library, which uses no display buffer.
There is also the option of using a different Arduino that has more memory.
Note that there is no problem with using 100% of the ROM memory, this is fixed at compile-time and will not change while the code is running.
I have merged your 3 closely related topics. I think all 3 can be summarised as you have having problems getting an OLED to work. People have replied with help in each topic, which you have then not responded to but instead opened another topic on the same subject. What you are doing is to waste the time of the volunteers trying to help you. If you continue to create new topics for the same problem then you are likely to be suspended from the forum for a while.
Please take the time to study the forum guide before posting again:
Did you read the lengthy thread i pointed to ?
And did you understand the answers given directly after your last reply ?
Do you understand the relation between those answers and your questions ?
If not, here's some thought:
These displays are graphic displays.
They aren't filling the display with text, the library draws those texts on it.
This is a fundamental difference.
To gain some speed, some libraries store the content of the screen in 2 pages (with the full size of that display each).
There's one page to display, and one to do the drawing on for the next display (because that takes some time).
After the drawing c.q. filling the page is done, the sketch can switch pages and so update the screen.
This may not be exactly what's going on, but it is close.
This also means you need a relatively large size of reserved memory for these pages.
If you are still using 2 libraries, you might have 4 pages reserved, or the pages may be conflicting.
If you want people to still help you, help them help you, by telling us what you did and what you learned from that.
Telling us "thanks for the help but it didn't work, so i now need some more help", makes it hard to understand where you are at that moment.
If someone still likes to help and throws something new at you to try, no one but you would know if that would be actually helping to you.
It might become a needless frustration.
So please tell what you have tried and what the conclusions were to you (who knows whether these are right or not).