I2C with u8g2 lib not working for 0.5 Inch OLED display Arduino shields.

Problems about those products which have a SZ2U tag on the Product page, please post topics on this module.

Moderators: lily.li, violet, jessie

Post Reply
eike.recker
Pre-kindergarten
Pre-kindergarten
Posts: 1
Joined: Sat Apr 13, 2019 12:06 am

I2C with u8g2 lib not working for 0.5 Inch OLED display Arduino shields.

Post by eike.recker » Sat Apr 13, 2019 12:14 am

Hi,

I have one of your 0.5 Inch OLED display Arduino shields.
Unfortunately I do not get it to work in I2C mode (resistors changed accordingly...) together with the U8G2 lib on my Arduino Micro and Arduino MicroPro. (I used HW pins 2 and 3 for I2C connection)

SPI Mode works perfectly with the display and u8g2 lib...

Can you please advice or provide a sample code and wirering schematic please to use the u8g2 lib.
Thank you

Best regrads

Eike

My code look slike this:
note: none of the constructors works for I2C...

#include <U8g2lib.h>


//U8G2_LD7032_60X32_F_4W_SW_SPI u8g2(/*rotation*/U8G2_R0, /* clock=*/ 3, /* data=*/ 2, /* cs=*/ 7, /* dc(A0)=*/ 6, /* reset=*/ 8);
//U8G2_LD7032_60X32_F_2ND_4W_HW_SPI u8g2(/*rotation*/U8G2_R0,/* cs=*/ 7,/* dc=*/ 6,/* reset=*/ 8);


//U8G2_LD7032_60X32_F_SW_I2C u8g2(/*rotation*/U8G2_R0,/* clock=*/ 3,/* data=*/ 2); //, /*reset=*/ 8)
//U8G2_LD7032_60X32_F_HW_I2C u8g2(/*rotation*/U8G2_R0);
U8G2_LD7032_60X32_F_HW_I2C u8g2(/*rotation*/U8G2_R0, /*reset=*/ 8);//,/* clock=*/ 3,/* data=*/ 2);

void setup(void) {
u8g2.begin();
}

void loop(void) {
u8g2.clearBuffer(); //lösche bildschirm puffer
u8g2.sendBuffer();
u8g2.setFont(u8g2_font_profont10_tf);
u8g2.drawStr(0,20,"Hello World!");
u8g2.sendBuffer();
delay(200);
}

User avatar
olikraus
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Sun Mar 31, 2019 12:44 am

Re: I2C with u8g2 lib not working for 0.5 Inch OLED display Arduino shields.

Post by olikraus » Tue Apr 23, 2019 4:22 am

Basically it should work. Can you post a picture of your setup?

Oliver

User avatar
olikraus
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Sun Mar 31, 2019 12:44 am

Re: I2C with u8g2 lib not working for 0.5 Inch OLED display Arduino shields.

Post by olikraus » Tue Apr 23, 2019 4:43 am


Post Reply