Using tft display in combination with SD module doesn't work

Hi everyone,

I have this tft st7789 display connected to a arduino nano every:

tft ST7789 display

The pins are connected as follows:

  1. GND -> ground of arduino
  2. VCC -> 3.3V
  3. SCL -> pin 13
  4. SDA -> pin 11 (COPI)
  5. RES -> pin 9
  6. DC -> pin 7

I run a graphics test example from the Adafruit libary and the display works as expected.

Now I want to read images from an SD card and display them on the display. I'm using this SD module:

SD module

And I connected it as follows:
GND -> ground of arduino
VCC -> 5V
MISO -> pin 12 (CIPO)
MOSI -> pin 11 (COPI)
SCK -> pin 13
CS -> pin 4

The SD module works also fine in a SD-test example I tried out (not using the tft display).

The problem now arises when I connect everything to the arduino and try to "talk" to both devices.

For example, this setup works fine and the tft display shows "Hello world" on the screen (using the custom testdrawtext() function):

void setup(void) {

  Serial.begin(9600);

  //pinMode(TFT_CS, OUTPUT);
  //digitalWrite(TFT_CS, HIGH);
  
  Serial.print(F("Hello! ST77xx TFT Test"));
 
  // if the display has CS pin try with SPI_MODE0
  tft.init(240, 240, SPI_MODE2);    // Init ST7789 display 240x240 pixel
  tft.fillScreen(ST77XX_BLACK);
 
  // if the screen is flipped, remove this command
  tft.setRotation(2);
 
  uint16_t time = millis();
  tft.fillScreen(ST77XX_BLACK);
  time = millis() - time;
 
  Serial.println(time, DEC);
  delay(500);
 
  // large block of text
  testdrawtext("Hello World!", ST77XX_WHITE);
  delay(1000);
}

But as soon as I add these lines regarding the SD module:

Serial.print("Initializing SD card...");
  if (!SD.begin(4)) {
    Serial.println("failed!");
  }
else {
     Serial.println("OK!");
  }

the display stays black but the SD card module gets initialized successfully.

I am a beginner regarding arduino in general so I might be not seeing something pretty obvious. There seems to be some communication problem when talking to both devices.
Is there a way to have both devices connected and then specify what device needs to be active a a specific point in time?

I followed a number of different tutorials (e.g. this one https://mytectutor.com/micro-sd-card-module-with-arduino-and-tft-display/ ) but they are either using a ST7735 display which has an additional CS pin which my display does not have (could this be the problem?) or they don't use an SD module.

I'm looking forward to any help I can get on this topic.

Best regards,
Luca

Thats a 5V Arduino, you appear to have it connected to a 3.3V display and SD card.

Is there logic level conversion fitted between the 3.3V of the display and the 5V of the Arduino ?

Hi, thanks for the quick reply.
The every also has a 3.3V output pin which I use to connect the tft. The SD module goes to the 5V pin.

Yes it has a 3.3V voltage supply pin, but the logic signals will still be 5V.

Your Display is 3.3V
The Nano Every has 5V logic.
An SD Card is 3.3V

You should connect the VCC pin on the Display to 3.3V
You should use level shifters on every signal.

Even when you provide the correct 3.3V logic signals there will be a problem with the SPI bus, Your Display has no CS pin.

I suggest that you either buy a Display with proper CS pin and level shifters or forget about the SD Card.

Otherwise you have to bit-bash one device on separate pins. Fine for simple SPI sensors. But both TFT and SD require fast SPI traffic.

David.

Hi David,
Thanks for the reply!

So if I buy a new display that uses a CS pin but still runs on 3.3V, I still need to use level shifters?

Is the only way not to use level shifters to buy another arduino with (3.3V logic) or a tft with 5V?

The real problem is "no CS". It means that you can't have any other SPI devices on the SPI bus. It would be the same problem with running on a Due.

Look at Adafruit Displays. They are all designed to work with 5V Arduinos.
Compare the number of components on an Adafruit pcb with the components on your Blue 3.3V Display or even the Red SPI displays that come with SD cards.

So yes, Adafruit and respectable Arduino display manufacturers all provide regulators and level shifters.

The cheap Chinese pcbs just expect 3.3V logic. Most provide a 3.3V regulator. Your particular pcb has no regulator and no level shifters.

Your display works nicely with 3.3V ESP32 or 3.3V RP2040. It will even display JPEG images, small animations, ... from Flash memory.
These "other" targets often have multiple hardware SPI buses. So they can put regular SPI devices (like SD) onto a separate bus.

David.

Thank you for your in depth response.
I will buy an adafruit display with integrated sd card and see if I can get it to work that way.

Best regards,
Luca