Help with ILI9431 TFT Screen + Arduino Mega 2560

Hello!

I come to you guys for help :slight_smile:. I bought a TFT screen and can't make it work and I am running out of ideas

This is the screen:
https://es.aliexpress.com/item/1005008716098015.html?spm=a2g0o.order_list.order_list_main.5.5ab7194dFhQXTS&gatewayAdapt=glo2esp

I am using an Arduino Mega 2560 and the adafruit ILI9341 library as the vendor specifies but I only manage to get a white screen.

I have tried replacing the wires, using another board (an Arduino UNO), and I have checked the connections many many times (pins 48 (DC), 49 (RST), 50 (MISO), 51 (MOSI), and 52 (SCK), 53(CS) + GRND + 5V).

I ran the graphictest example from the library and got lots of info, and according to chatgpt the problem could be in the MISO pin).

Extract of test:
ILI9341 Test!
Display Power Mode: 0x0
MADCTL Mode: 0x0
Pixel Format: 0x0
Image Format: 0x0
Self Diagnostic: 0x0
Benchmark Time (microseconds)
Screen fill 1496768
Text 154492
Lines 1268804
(I got reasonable values in every of the following points).

Any insight would be very helpful. Thanks a lot

If you are not using this example code from Adafruit, then say what code you are using to test this ILI9341 based display: Adafruit_ILI9341/examples/graphicstest/graphicstest.ino at master · adafruit/Adafruit_ILI9341 · GitHub

In this example, the screen reset pin is not configured by default. In this case, it should be pulled high with a 10k resistor.

Thanks a lot for the answer! I am using precisely that example.
I am a beginner in these topics, how can you tell that the reset pin should be handled like that?

That example was for a Uno or Nano and did not explicitly use the screen reset pin. Can you show how you modified it for the Mega because the pins are different for the Mega. Include the whole program if necessary.

although the link in post 1 states “Compatible con 5V, uso con lógica de 3,3V o 5V” (5V compatible, use with 3.3V or 5V logic) in general this type of display even if powered from 5V (link J1 is open) the display interface logic level is still 3.3V

connecting directly to UNO/MEGA/etc GPIO pins which use 5V logic can damage the display

I will send you the exact code once I get home. But if I recall correctly I only changed the definitions for the pins at the beginning of the code

#define TFT_CS    53
#define TFT_DC    48
#define TFT_RST   49

I think this could be the problem, I have really tested many things and I have found other posts about TFT screens not being really 5V.
The TFT screen looks like a good choice for my project. What would you do on my situation? Just buy another TFT screen or another microcontroller board that supports 3.3V logic?

I would move to a microcontroller which uses 3.3V logic - I would use an ESP32 which is supported by the Arduino IDE, e.g.

EDIT: also worth looking at are ESP32-Cheap-Yellow-Display
main problem is VERY limited IO facilities

1 Like

If you are using the code base as in the link in post #1 then you have to make changes to the code below to match your Mega (original code shown).

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

// For the Adafruit shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// If using the breakout, change pins as desired
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

Note that the constructor which uses the screen reset pin is commented out and this pin should not be allowed to float.

I also have some experience with these ILI9341 screens (touch version) using ESP8266 and ESP32 but not used these with a 5v logic device such as a Uno. Logic level shifters would also be an option if, for example, you chose the Mega because you needed a huge number of GPIO pins.

1 Like

thanks a lot for the recommendation and the example! I will try the ESP32

Thanks for the help, I will double check this

if you need to use a Mega have a look at displays which plug into UNOs etc, e.g. mcufriend-2-4-tft-display
the problems of 5V/3.3V logic conversion are handled on the PCB