Hello,
I am using 3.5" TFT LCD Shield with Arduino Uno and its work great, but in other project i can't use with esp32 SPI connection. Please guide me how to solve this issue?
What is the issue? You said nothing about it.
Please read the forum guidelines that helps you to describe the problem properly.
Where is your code? And connection diagram?
| Function | Display Pin (UNO Shield) | ESP32 Pin |
|----------------|--------------------------|------------|
| Power GND | GND | GND |
| Power 3.3V | 3.3V | 3.3V |
| Power 5V | 5V | VIN |
| LCD_CS | D10 | GPIO 27 |
| LCD_DC | D9 | GPIO 14 |
| LCD_RST | D8 | GPIO 26 |
| LCD_WR | D7 | GPIO 12 |
| LCD_RD | D6 | GPIO 13 |
| LCD_D0 | D2 |GPIO 16(RX2)|
| LCD_D1 | D3 | GPIO 4 |
| LCD_D2 | D4 | GPIO 23 |
| LCD_D3 | D5 | GPIO 22 |
| LCD_D4 | D6 | GPIO 21 |
| LCD_D5 | D7 | GPIO 19 |
| LCD_D6 | D8 | GPIO 18 |
| LCD_D7 | D9 |GPIO 17(TX2)|
this is my wiring and i use TFT_eSPI library with this setting in User_setup.h :
// ########################## USER DEFINED SETTINGS ##############################
// Define the ILI9488 display driver
#define ILI9488_DRIVER
// Define the pins for ILI9488
#define TFT_CS 27 // Chip Select
#define TFT_RST 26 // Reset
#define TFT_DC 33 // Data/Command
#define TFT_WR 32 // Write
#define TFT_RD 25 // Read
// Define the data pins (D0 to D7)
#define TFT_D0 5
#define TFT_D1 18
#define TFT_D2 19
#define TFT_D3 21
#define TFT_D4 22
#define TFT_D5 23
#define TFT_D6 14
#define TFT_D7 12
// Optional: Define the touch screen control pin
#define TOUCH_CS -1 // Chip select pin for touch screen (optional)
// Optional: Set the backlight control pin if your screen has backlight
#define TFT_BL 32 // LED back-light control pin
#define TFT_BACKLIGHT_ON HIGH // Level to turn ON back-light (HIGH or LOW)
// Optional: Set the colour order if needed (swap Red/Blue)
#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
// Optional: Enable inversion if the colours appear incorrect
// #define TFT_INVERSION_ON
and this is my sample sketch for test:
#include <TFT_eSPI.h> // Include the TFT library
TFT_eSPI tft = TFT_eSPI(); // Create TFT object
void setup() {
// Initialize TFT
tft.init();
tft.setRotation(1); // Adjust rotation as needed
tft.fillScreen(TFT_BLACK); // Clear screen
// Set text color and size
tft.setTextColor(TFT_WHITE);
tft.setTextSize(2);
// Display text
tft.setCursor(50, 50);
tft.print("Hello World!");
}
void loop() {
// Nothing needed here for this example
}
in start screen is white after is see gray and not data"Hello World"
As I see, your pins are not the same as recommended in the library:
It could be a problem, because these pins D0-D7 can't be choosed freely. Read the library documentation.
I recommended you, as a start - connect the display to the pins, exactly the same as in the library's example.
LCD_CS | GPIO 27 |
---|---|
LCD_RST | GPIO 26 |
LCD_DC (or LCD_RS) | GPIO 33 |
LCD_WR | GPIO 32 |
LCD_RD | GPIO 25 |
D0 (Data 0) | GPIO 5 |
D1 (Data 1) | GPIO 18 |
D2 (Data 2) | GPIO 19 |
D3 (Data 3) | GPIO 21 |
D4 (Data 4) | GPIO 22 |
D5 (Data 5) | GPIO 23 |
D6 (Data 6) | GPIO 14 |
D7 (Data 7) | GPIO 12 |
My connection is like this now, and my commands in User_Setup.h are like this:
// ########################## USER DEFINED SETTINGS ##############################
// Define the ILI9488 display driver
#define ILI9488_DRIVER
// Define the pins for ILI9488
#define TFT_CS 27 // Chip Select
#define TFT_RST 26 // Reset
#define TFT_DC 33 // Data/Command (or RS)
#define TFT_WR 32 // Write
#define TFT_RD 25 // Read
// Define the data pins (D0 to D7)
#define TFT_D0 5 // Data 0
#define TFT_D1 18 // Data 1
#define TFT_D2 19 // Data 2
#define TFT_D3 21 // Data 3
#define TFT_D4 22 // Data 4
#define TFT_D5 23 // Data 5
#define TFT_D6 14 // Data 6
#define TFT_D7 12 // Data 7
// Optional: Define the touch screen control pin
#define TOUCH_CS -1 // Chip select pin for touch screen (optional)
// Optional: Set the colour order if needed (swap Red/Blue)
#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
// Optional: Enable inversion if the colours appear incorrect
// #define TFT_INVERSION_ON
I see... and it still not the same as in the library example...
looks like the display in post 1 is designed to plug into and to work with a UNO - as you say it works OK
I would suggest you look at TFT designed to work with ESP32 and similar 3.3V logic microcontrollers, e.g. HiLetgo 240X320 Resolution 2.8" SPI TFT LCD Display Touch Panel ILI9341 - cost about £13 in UK
the TFT_eSPI display library supports such displays including touch functionality
Maybe it is interesting to check this one:
success, Photoncatcher
For the life of me I couldn't get my Nano ESP32 to work with ILI9488 screen. Using an example program that came with TFT_eSPI library, modified pin assignments in the setup files, compiled without errors using Arduino IDE, and uploaded to Nano ESP32. Unfortunately, the Nano went unresponsive with blinking rainbow LED light. It just does not like the successfully compiled program.
Interestingly, the same example program works with UNO board. Please let me know if you are able to get Nano ESP32 to work with ILI9488.
For now I have switched to a 16x2 LCD display in I2C mode and it works.
not got a Nano ESP32 but have had the tft-lcd-2-8-240x320-rgb-spi-display-with-touchscreen working with an ESP32 and ESP-CAM
in directory C:\Users\bb\Documents\Arduino\libraries\TFT_eSPI you need to update some files
// in file TFT_eSPI/User_Setup_Select.h uncomment the following statement
// #include <User_Setups/Setup42_ILI9341_ESP32.h> // Setup file for ESP32 and SPI ILI9341 240x320
// EDIT file TFT_eSPI/User_Setups/Setup42_ILI9341_ESP32.h check the pin definitionss are correct for the board
// #define ILI9341_DRIVER
//
// #define TFT_MISO 19 // (leave TFT SDO disconnected if other SPI devices share MISO)
// #define TFT_MOSI 23
// #define TFT_SCLK 18
// #define TFT_CS 15 // Chip select control pin
// #define TFT_DC 2 // Data Command control pin
// #define TFT_RST 4 // Reset pin could connect to RST pin or Pull to 3.3V if not using.
// 5Volt power to display VCC if J1 is open
you need to change TFT_MOSI etc to suit the ESP32 pins used to connect to the display
try a simple example, e.g. File>Examples>TFT_eSPI>320x240>TFT_Print_Test
Thanks for responding. There are many ESP32 boards under different brands. It seems that the Arduino ESP32 is challenging to work with TFT_eSPI library. It compiles but goes to confused state once uploaded to the board. Enough time spent on this board.
you only have to get the pin setting incorrect in the TFT_eSPI library setup and the ESP32 will loop throwing exceptions