Hello everyone,
In my project, I'm using an Arduino UNO with a 128x64 OLED display from Adafruit, which was originally designed to work with a Raspberry Pi. The screen works correctly on the Arduino (thanks to the Adafruit_SSD1306 library). At first, I can display text or graphical elements without any issues. However, as soon as I touch the Arduino or move the device even slightly, the screen goes completely black.
The only way to get it back to normal is by pressing the "reset" button, but otherwise, the screen does not reset itself.
Here is the code I’m using to test the display:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_ADDR 0x3C // 7-bit I2C address
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
// Serial initialization for debugging
Serial.begin(9600);
// I2C connection test
Wire.begin();
Wire.beginTransmission(OLED_ADDR);
if(Wire.endTransmission() != 0) {
Serial.println("I2C error - Check the wiring!");
while(1);
}
// Screen initialization
if(!display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR)) {
Serial.println("Memory allocation failed");
while(1);
}
// Display configuration
display.clearDisplay();
display.setTextSize(1); // Medium size
display.setTextColor(WHITE); // Required color
display.setCursor(15, 25); // Approximate position
display.print("Hello World");
display.display();
}
void loop() {}
Setup details:
- The screen is connected to the Arduino via the I2C bus.
- The screen is powered at 3.3V using the Arduino's 3.3V and GND pins.
- I have checked the wiring, and it seems correct (SDA and SCL are properly connected to pins A4 and A5).
Hypotheses:
- I noticed that the Arduino operates at 5V, while the Raspberry Pi (which I am replacing here) provides 3.3V on its I2C pins. Could this cause a compatibility issue? Maybe the display, which is originally designed for a Raspberry Pi, is more sensitive to voltage variations due to the 5V signals from the Arduino on pins A4 and A5?
- Could vibrations or voltage variations on the I2C bus be disrupting communication? I wonder if using a diode to drop the voltage to 3.3V could solve the issue (or a capacitor).
I have already tried adding a diode and a capacitor without success. Since I’m a beginner in electronics, maybe my circuit or the components I used were not the right ones.
Demo :
PS : I even tried securing the OLED screen connections to avoid any loose contact, but even while holding the wires firmly and moving only the Arduino, the issue persists: the screen turns black
Thanks in advance for your feedback and advice!
Link of the OLED screen : Adafruit 128x64 OLED Bonnet for Raspberry Pi : ID 3531 : Adafruit Industries, Unique & fun DIY electronics and kits