OLED does not work on External Power on Arduino Mega

Hello, I have a cheap OLEd display that I use with Arduino Mega using greiman/SSD1306Ascii library.

OLED is connected to 3V and I'm using software SPI on pins : OLED_DC 32 OLED_CS 30 OLED_CLK 38 OLED_DATA 36

Everything is fine when I power using computers USB cable however when I plug a 12v 1a power adapter the display is all garbled, most of the times it doesnt work. Do oleds have issues with external power?

I suspect this is the usual 5V logic problem.

I am guessing you have connected the logic lines direct the the display.

Probably scenario is:

When on USB power typical Megas run at 4.6V due to voltage drops. The display is rated at 4V max so probably just copes with the overvoltage on the logic lines. When you connect 12V to the Mega it runs at 5V and the logic lines now overdrive the display.

The other possible cause is common mode noise spikes coming out of the 12V power supply (this is a problem with some very cheap switched mode “Wall wart” power supplies).