SSD1351 OLED Display and SD Card not working simultaneously

I am working with Adafruit’s SSD 1351 OLED display, which works just fine with this library In addition, the SD card of this display works as well, when using the SD-Card-Library on the web IDE. However, if I want to use display and SD card simultaneously, writing on the SD card does not work any more. As soon as initialize the display with tft.begin();, no data is written on the SD card. Writing data on the SD card works fine, as long as the display is not initialized. Code was complied and flashed with web IDE without any problems.

Any ideas what could be wrong?

Here is my code;

#include "application.h"
#include "sd-card-library/sd-card-library.h"
#include "Adafruit_mfGFX.h"
#include "Adafruit_SSD1351.h"

File myFile;

#define sclk A3 //2
#define mosi A5 //3
#define dc D3 //4
#define cs A2 //5
#define rst D2 //6

#define    BLACK 0x0000
#define    BLUE 0x001F
#define    RED 0xF800
#define    GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

const uint8_t chipSelect = A1;  
const uint8_t mosiPin = A5;
const uint8_t misoPin = A4;
const uint8_t clockPin = A3;

Adafruit_SSD1351 tft = Adafruit_SSD1351(cs, dc, rst);

void initializeSDCard(){

    // TFTDisplay.text("Initializing SD card...", 0, 70);
    tft.println("Initializing SD card...");

    if(! SD.begin(mosiPin, misoPin, clockPin, chipSelect)){
        // TFTDisplay.text("Card failed, or not present", 0, 80);
        tft.println("Card failed, or not present");
        // TFTDisplay.text("card initialized",0,80);
        tft.println("Card initialized");

void setup()


int fsr1 = analogRead(A0);
File dataFile ="data21.txt", FILE_WRITE);


tft.println("Hello World!");

void loop()

1 Like

@pteja I believe that the problem lies in the fact that the ssd1351 uses SPI mode 3 and the SD uses mode 0. I will investigate. :smile:

Have a look at the digole display thread, there is a work around in there… but it’s not nice… reinitialise the card after every access to the display

Another approach would be to use software SPI for the display. That is something I need to test with the dipole as well.

Using software SPI worked! I simply changed

Adafruit_SSD1351 tft = Adafruit_SSD1351(cs, dc, rst);


Adafruit_SSD1351 tft = Adafruit_SSD1351(cs, dc, mosi, sclk, rst); 

and everything is working now. Thanks so much!

1 Like

Hi Pteja. This thread was fairly helpful to me but I’m still having a very similar issue. The trouble is I’m not using the same OLED library as you so I can’t apply this solution.

I’m going to test this OLED library to see if I can get it to work with my smaller

my issue: