OLED_I2C Library for ssd1306 random dots

kokospalme
Fri May 04, 2018 11:11 am
Hello everyone!
I have some OLED Displays here but I can’t get them working, unfortunately with none of the libraries I found in the core library folder (adafruits ssd1306, OLED_I2C are both not working). I could get the u8g2 working either…
Only with the OLED_I2C library something is shown on the Displays (0.96″ OLED and 0.49″ OLED): only some random dots appearing… :?

question 1:
am I doing something wrong?

question 2:
should this library also works wir an 0.66″ Display (64×48 dots)?

This is my code:

#include <OLED_I2C.h>

OLED myOLED(SDA1, SCL1, PB8);

extern uint8_t TinyFont[];

void setup()
{
myOLED.begin();
myOLED.setFont(TinyFont);
myOLED.clrScr(); //clear Display
}

void loop()
{

myOLED.print("Hello W.", 10,10);
myOLED.update();
delay(1000);

}


ahull
Fri May 04, 2018 11:40 am
Maybe if you provided a few pictures of the displays and perhaps a link to the seller or source, that might help.

stevestrong
Fri May 04, 2018 11:52 am
5V <-> 3.3V conflict?

kokospalme
Fri May 04, 2018 12:18 pm
0.49″ Display:
https://www.ebay.de/itm/White-Blue-0-49 … 2749.l2649

0.66″ Display:
https://www.ebay.de/itm/0-66inch-OLED-D … 2749.l2649

0.96″ Display:
https://www.ebay.de/itm/0-96-6Pin-12864 … 2749.l2649

They all run on 3.3V, so I don’t think it has something to do with the voltages… :(


stevestrong
Fri May 04, 2018 12:25 pm
Pull up resistors connected? Which value? Are they adapted to the I2C bus speed?

kokospalme
Fri May 04, 2018 12:52 pm
I have connected 2.2k resistors as Pull ups, but that doesn’t affect anything. There are several settings in the .h files:

in “HW_STM32_defines.h”:
// *** Hardwarespecific defines ***
#define cbi(reg, bitmask) *reg &= ~bitmask
#define sbi(reg, bitmask) *reg |= bitmask
#define pulseClock cbi(P_SCK, B_SCK); asm ("nop"); sbi(P_SCK, B_SCK)

#define fontbyte(x) cfont.font[x] #define bitmapbyte(x) bitmap[x]

#define bitmapdatatype unsigned char*

#define SDA1 PB11
#define SCL1 PB10
#define SDA PB7
#define SCL PB6

#define TWI_SPEED TWI_SPEED_400k // Set default TWI Speed
#define TWI_SPEED_100k 208
#define TWI_SPEED_400k 101

#define TWI_DIV TWI_DIV_400k // Set divider for TWI Speed (must match TWI_SPEED setting)
#define TWI_DIV_100k 1
#define TWI_DIV_400k 0


stevestrong
Fri May 04, 2018 5:41 pm
Don’t know, I don’t have any OLED display, so I cannot tell you what can be wrong there.
Don’t you get some warnings during building the project?
I see an active electronic component on the back side of the first board, what can it be?
If it is a voltage regulator, that may cause some trouble.
Have you checked the I2C pins for any useful signal with scope?

madias
Fri May 04, 2018 6:46 pm
Just tested on my maple mini:
Try out Adafruit_SSD1306 (in the STM32 F1 library folder!) Take the “ssd1306_128x64_i2c_STM32” example.
Connection is on I2c Port 1 (edit!)
I adapted the library years ago, seems that there were many changes in I2c since them.
Output is VERY slow now…but it works. (If i have time, I’ll examine it) CORRECTED: See next post
OLED_I2C (also in library F1 folder) is totally broken – even changing HWIRE to Wire. But you can use soft-i2c: Choose any other pin than SDA/SCL or SDA1/SCL1, for example:
OLED myOLED(PA4, PA3);

madias
Fri May 04, 2018 8:38 pm
Ok, Wire is now slow because of the default Hz rate, just insert a
Wire.setClock(400000);

kokospalme
Sat May 05, 2018 10:25 pm
So I have to use the adafruit ssd1306 library because the OLED_I2C lib is some kind fo messed up and doen’t work at all?

madias
Sun May 06, 2018 10:28 pm
If you need HW-SPI for speed, use the adafruit one (with my modifications in the upper post)
If you don’t need speed and using any free pins, use the other one (as I explained)
On a 128×64 monochrome display I prefer to save my SPI port(s) and doing it “soft”

Leave a Reply

Your email address will not be published. Required fields are marked *