olikraus / u8g2

U8glib library for monochrome displays, version 2
Other
5.07k stars 1.05k forks source link

Library gets stuck with OLED SSH1106 and Arduino UNO #2347

Open Alejandro13C opened 8 months ago

Alejandro13C commented 8 months ago

Hi all,

I have connected Arduino UNO with ZDelivery 1,3" OLED Display I2C SSH1106 Chip 128 x 64. I try to use a simple clock example but when i connect the Ardunio UNO at OLED.

5V --> 5V arduino. GND--> GND Arduino. SDA --> A4 SCL --> A5

#include <U8g2lib.h>
#include <Wire.h>

U8G2_SH1106_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0,4,5, /* reset=*/ U8X8_PIN_NONE);

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

uint8_t s = 00;
uint8_t m = 00;
uint8_t h = 00;

char s_str[3];
char m_str[3];
char h_str[3];

void loop(void) {

  strcpy(s_str, u8x8_u8toa(s, 2));      /* convert m to a string with two digits */
  strcpy(m_str, u8x8_u8toa(m, 2));      /* convert m to a string with two digits */
  strcpy(h_str, u8x8_u8toa(h, 2));      /* convert m to a string with two digits */
  u8g2.firstPage();
  do {
    u8g2.setFont(u8g2_font_ncenB10_tr);
    u8g2.drawStr(10,63,h_str);
    u8g2.drawStr(33,63,":");
    u8g2.drawStr(50,63,m_str);
    u8g2.drawStr(73,63,":");
    u8g2.drawStr(90,63,s_str);
    Serial.print("u8g2.nextPage(): "); Serial.println(u8g2.nextPage());
  } while ( u8g2.nextPage() );

  delay(1000);
  s++;
  if ( s == 60 )
  {
    s = 0;
    m++;
  }
  if ( m == 60 )
  {
    m = 0;
    h++;
  }
  if (h == 24)
  {
    h = 0;
  } 
}

The program is in stuck at this instruction. while ( u8g2.nextPage() ) I had the same problem when i use "u8g2.sendBuffer();" I see the issue onyl when i connect the oled to the Arduino. I check the same OLED with ESP32 and i do not see any issue. I check the same OLED with another Arduino UNO i reproduce the issue. Could you help me? Thanks!

olikraus commented 8 months ago

Your constructor U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0,4,5, /* reset=*/ U8X8_PIN_NONE); seems to be wrong.

Use U8G2_SH1106_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0,4,5, /* reset=*/ U8X8_PIN_NONE); or U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0,/* reset=*/ U8X8_PIN_NONE);

Alejandro13C commented 8 months ago

Hi @olikraus

This constructor does not work. 8G2_SH1106_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0,4,5, / reset=/ U8X8_PIN_NONE); The code is not running with this.

With the other. U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0,/ reset=/ U8X8_PIN_NONE); I see the issue after 15 minutes

Regards

olikraus commented 8 months ago

Then? Is your problem solved?

Alejandro13C commented 8 months ago

Hi, No, i still have the issue. I check that when i disconnect only the SCL pin of the OLED display, the code is running. Could be possible that the frecuency is not setting properly?

Some new Updates.

I change the wire between OLED and Arduino, i use a longer wire. If i check the i2c address of the oled i see it:

2:05:40.295 -> Scanning... 12:05:40.295 -> I2C device found at address 0x3C ! 12:05:40.295 -> done

But if i try to run the clock example, the code get stuck at : u8g2.begin();

Thanks!

olikraus commented 8 months ago

But if i try to run the clock example, the code get stuck at : u8g2.begin();

Looks like you need a 10K pullup resistor for the I2C bus.

Alejandro13C commented 3 months ago

Hi,

I use a 10k pullup with external powersupply and the code is stuck at the same point. :(

Regards,

olikraus commented 3 months ago

Hmm.. I never heard, that the "SW_I2C" can cause such trouble. Strange...