Hi,
I've been desperately trying to get my Arduino Pro Mini and OLED working via hardware I2C and failing.
A4 -> SDA
A5 -> SCL
Hardware:
- Arduino Pro Mini Atmega168 Module 5V 16MHz
- SSD1306 I2C 0.91" 128x32 white OLED
- 2 x 4K7 pull up resistors
Code:
#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
void setup(void) {
u8g2.begin();
}
void loop(void) {
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font
u8g2.drawStr(0,10,"Hello World!"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
This code all compiles and uploads fine, but nothing shows on the display.
If however I use software I2C...
U8G2_SSD1306_128X32_UNIVISION_F_[b]SW[/b]_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);
...everything works as expected and the display shows.
Am I missing some code? Do I need to define the I2C pins in the constructor call for HW I2C?
What am I missing?
Thank you!