Page 1 of 1

Software I2C U8g2Lib doesn't work

Posted: Sun Jan 08, 2023 1:26 pm
by zjm001
Hello guys,
I tried to use the 128X64 OLED by using U8g2Lib's software I2C , but it doesn't work.
However, I used the same code on Arduino UNO,and it worked well (except pins definations).
My chip is STM32F103ZET6
SDA => PF8
SCL => PF10
Please recommand me a usable lib if this actually a bug.
Below is my code.
Thank you :D .

Code: Select all

#include <U8g2lib.h>
#include <Wire.h>
#define SCL_OLED PF10
#define SDA_OLED PF8
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /*clock=*/SCL_OLED, /*data=*/SDA_OLED, /*reset=*/U8X8_PIN_NONE);
void setup() {
  pinMode(SDA_OLED, OUTPUT);
  pinMode(SCL_OLED, OUTPUT);
  u8g2.begin();
  u8g2.enableUTF8Print(); // enable UTF8 support for the Arduino print() function
}

void loop() {
  u8g2.setFont(u8g2_font_unifont_t_symbols);
  u8g2.firstPage();
  do
  {
    u8g2.setCursor(0, 15);
    u8g2.print("Hello World!");
  } while (u8g2.nextPage());
  delay(1000);
}

Re: Software I2C U8g2Lib doesn't work

Posted: Sun Jan 08, 2023 1:57 pm
by fpiSTM
Why not use the hardware I2C?

Re: Software I2C U8g2Lib doesn't work

Posted: Sun Jan 08, 2023 2:18 pm
by zjm001
Well, my I2C bus has some devices that can't be set address in their init functions. At the same time,U8g2Lib also provides the SW init function,so I want to use the software I2C to use the OLED . :)

Re: Software I2C U8g2Lib doesn't work

Posted: Sun Jan 08, 2023 2:24 pm
by zjm001
fpiSTM wrote: Sun Jan 08, 2023 1:57 pm Why not use the hardware I2C?
The hardware I2C is tested OK,but the software I2C is also failed.

Re: Software I2C U8g2Lib doesn't work

Posted: Tue Jan 10, 2023 4:42 am
by ag123

Re: Software I2C U8g2Lib doesn't work

Posted: Wed Jan 11, 2023 8:33 am
by fpiSTM
I already use the SW I2C of this library with another mcu and it works.
Maybe timing issue if you used the internal clock (HSI)?

Re: Software I2C U8g2Lib doesn't work

Posted: Wed Feb 22, 2023 1:09 am
by hotxxw
I also encountered the same situation. The hardware I2C is OK, but the software I2C is unrealistic. Have you solved this problem?