TFT display not displaying fully

Hello, everyone. I am working with a 240x320 TFT display and have a problem where part of the screen doesn't work. Here is the code I am running and a picture of the screen. I am using esp32-s3

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>

#define TFT_DC 2
#define TFT_CS 39
#define TFT_MOSI 35
#define TFT_CLK 36
#define TFT_RST 4
#define TFT_MISO 37

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

void setup() {
  Serial.begin(115200);

  tft.begin();
  tft.setRotation(1);
  tft.fillScreen(ILI9341_RED);  
  tft.setTextSize(2);
}

void loop() {
  tft.fillScreen(ILI9341_RED);
  tft.fillScreen(ILI9341_WHITE);
  tft.fillScreen(ILI9341_BLUE);
}

Any idea why?

How about checking how the library recognizes the width and height with the following code?

Serial.println(tft.width());
Serial.println(tft.height());

Try

tft.setRotation(0);

instead

tft.setRotation(1);

TL;DR: you may not have an ILI9341, you may have an ST7789 controller.

A read through of this topic from a couple of years ago may prove useful in solving your display problem.

You are facing probably the same issue I was. If you are using the TFT_eSPI library, go into the User_Setup.h file and comment out ILI9341_DRIVER and uncomment ILI9341_2_DRIVER.

It should look like this. Make sure you save the file afterwards.

Screenshot 2024-12-18 at 11.24.33 PM

my HiLetGo 240X320 Resolution 2.8" SPI TFT LCD Display Touch Panel ILI9341 looks identical to yours
works OK with your code of post filling screen red white blue

only change I made was to the pin assignments

// ESP32 connections
#define TFT_CS    15
#define TFT_DC    2
#define TFT_MOSI  23
#define TFT_CLK   18
#define TFT_RST   4
#define TFT_MISO  19

how do you power the display?
all the documentation I have seen on this type of display states that
if J1 is shorted supply 3.3V on VCC
if J1 is open supply 5V on VCC
e.g. By solder shorting the two J1 pads together, the 5volt regulator is bypassed and the module can be powered directly from 3.3V.

if you are powering from 5V the display logic level is still 3.3V - do not connect directly to UNO/MEGA/etc GPIO pins which use 5V logic - use level converters

Hi, thanks for the reply. It worked, as you mentioned. I tried the Adafruit ST7789 library, and now the display is fully used!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.