SSD1306 OLED Screen Turns Black with any small movement (I2C, Arduino)

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 :

ezgif-212c0ec918b22d

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

Looks like faulty connections to me. Pushing pins into holes doesn't work well. Dupont cables are notorious for faults like fractured conductors.

Solder some pins or sockets to that hat, try different Dupont cables and test each cable before use with your multimeter.

Soldering your wires to the display will hold them firmly. Or soldering a header to the display.

Anything else is just kidding yourself and wasting time.

How exactly are the jumpers connected to the screen ?

on my experience these female terminals on the UNO are a real pain in the butt. For me it was this bad that I do not use Arduino UNO anymore.
You can solder male terminals beside the females on the UNO and use female Dupont cables. the male terminals are better to handle and make better contacts.

Thank you for your quick responses. In hindsight, the loose connection seems to be the most likely issue. It happens when I touch one of the cables, and it appears to be at the Arduino level. However, I can't seem to find cables that are as thick as the Raspberry Pi GPIO pins for a secure fit.

Since the sensors and the screen use a round connector, I need a cable thick enough to avoid any gaps. I'm not very comfortable with soldering, so I'd rather avoid it if possible.

Do you think this wire kit would help ? I currently have cables with round ferrules, so if I switch to square male ferrules, that should help, I think.

[ELEGOO Lot de 120pcs Câbles Dupont Breadboard 28AWG 3 en 1 [40Pin Mâle vers Femelle, 40Pin Mâle vers Mâle, 40Pin Femelle vers Femelle] Longueur 20cm pour Mega modèle de 2560 Nano ou Plaque d'Essai : Amazon.fr: Informatique](https://Wires kit)

Not in the least. But it's your time to waste. You'll eventually figure out that you have to solder things. Why not now?

If you are happy with projects that work only when you happen to wiggle the right wires, fine.

Otherwise, Sparkfun and Adafruit have excellent soldering tutorials. Keep in mind that ten year old children have mastered the art.

The project I'm working on has to be ready in 2 months, and we have a monstrous amount of work to do (we have to develop a whole ecosystem around the project using the arduino). I absolutely have to prioritize things if I hope to have a working test version, even if it means having a version that's still only a proof of concept.

Of course, if short circuits become too recurrent even with the new cables, I'll learn to solder.

If I were you I would prioritise learning to solder

Okay, I'll think about it. Thanks for your feedback and help.

EDIT : I received the cables I mentioned above and everything is working fine now. I bought a brazing kit that I can't wait to try.