3.5" ILI9488/ILI9486 w ESP32

Hey all,

I am trying to get a 3.5" RPi Touch Display (XPT2046, 320x480) working with a generic ESP8266 (OR a Particle Photon, but doesn't seem possible). I've wired up the display to match the above posts, but am only getting a dark bar 1/3rd the screen no matter what I try. See the code below, I've went in and changed User_Select.h and tried to define the variables myself to ensure they're catching, with no luck.

#include <SPI.h>

#define D0 16
#define D1 5 // I2C Bus SCL (clock)
#define D2 4 // I2C Bus SDA (data)
#define D3 0
#define D4 2 // Same as "LED_BUILTIN", but inverted logic
#define D5 14 // SPI Bus SCK (clock)
#define D6 12 // SPI Bus MISO
#define D7 13 // SPI Bus MOSI
#define D8 15 // SPI Bus SS (CS)
#define D9 3 // RX0 (Serial console)
#define D10 1 // TX0 (Serial console)

#include <TFT_eSPI.h>
#include <User_Setups/Setup10_RPi_touch_ILI9486.h>
#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts

#include <TFT_Drivers/RPI_ILI9486_Defines.h>

#define GFXFF 1
#define GLCD  0
#define FONT2 2
#define FONT4 4
#define FONT6 6
#define FONT7 7
#define FONT8 8
#define TFT_WR PIN_D2
#define TFT_CS   D8  // Chip select control pin D8
#define TFT_DC   D3  // Data Command control pin
#define TFT_MISO D6
#define TFT_MOSI D7
#define TFT_SCLK D5
#define TFT_RST  -1  // Reset pin (could connect to NodeMCU RST, see next line)
#define TOUCH_CS D1     // Chip select pin (T_CS) of touch screen
#define RPI_ILI9486_DRIVER // 20MHz maximum SPI



#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <SPI.h>
#include <Wire.h>

/*
 * 
 * 1) Download the latest Arduino environment (use Google). I am using 1.8.3 on Windows 7.
2) Follow the guide on sparkfun regarding installing the 8266 in the arduino environment. Google "sparkfun installing 8266 guide" and it should be the top link.
3) You must also have the Silicon Labs CP210x USB to UART Bridge driver installed (probably need to reboot). It is available for most major OS's. Use Google to find the driver. Verify that (in windows) your Device Manager lists this driver in the PORTS part of the tree. It will also show your COM port for your ESP8266 next to it. If it doesn't show, then nothing else will work.
4) Now in the Tools menu you will need to setup for your board. Everything after this is under the Tools menu in the Arduino environment.
Set Board -> Generic ESP8266 Module (OR NodeMCU 1.0)
Set Flash Mode -> DOUT
Leave Upload Speed -> 115200
6) Hold the flash button on the board while uploading the code from the Arduino environment. I suggest the back side of a pencil since you will be holding it a while. Although may work by not foing this
7) Click reset on the board to start the program.
 */
#include <Adafruit_GFX.h>






const char* ssid = "network-ssid";
const char* password = "pasphrase";

ESP8266WebServer server(80);

TFT_eSPI tft = TFT_eSPI();


void handleRoot() {
  server.send(200, "text/html", "<html><body>hello from esp8266!</body></html>");
}

void handleNotFound(){
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
}

void setup(void){
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");

  tft.init();
  // init done

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  server.on("/", handleRoot);
  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void){
  server.handleClient();

   int xpos =  0;
  int ypos = 40;

  tft.setTextColor(TFT_YELLOW, TFT_BLACK);
  tft.setCursor(xpos, ypos);    // Set cursor near top left corner of screen

  tft.setTextFont(GLCD);     // Select the orginal small GLCD font by using NULL or GLCD
  tft.println();             // Move cursor down a line
  tft.print("Original GLCD font");    // Print the font name onto the TFT screen
  tft.println();
  tft.println();
}

blandman:
Hey all,
I've wired up the display to match the above posts, but am only getting a dark bar 1/3rd the screen no matter what I try

I have upload your scetch to my WEMOS D1 mini and RPI Display, all working. At least display working correctly. I have add a yellow background in line 72 for make sure, that display is operational.
Take care, that reset pin must be connected to D4, but not to common reset of ESP8266 board!
But it seems, the are many excess records was in code, so i little reduced it:

#include <SPI.h>
#include <TFT_eSPI.h>
//#include <User_Setups/Setup10_RPi_touch_ILI9486.h>
#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts

#define GFXFF 1
#define GLCD  0
#define FONT2 2
#define FONT4 4
#define FONT6 6
#define FONT7 7
#define FONT8 8

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <Wire.h>

/*
 * 
 * 1) Download the latest Arduino environment (use Google). I am using 1.8.3 on Windows 7.
2) Follow the guide on sparkfun regarding installing the 8266 in the arduino environment. Google "sparkfun installing 8266 guide" and it should be the top link.
3) You must also have the Silicon Labs CP210x USB to UART Bridge driver installed (probably need to reboot). It is available for most major OS's. Use Google to find the driver. Verify that (in windows) your Device Manager lists this driver in the PORTS part of the tree. It will also show your COM port for your ESP8266 next to it. If it doesn't show, then nothing else will work.
4) Now in the Tools menu you will need to setup for your board. Everything after this is under the Tools menu in the Arduino environment.
Set Board -> Generic ESP8266 Module (OR NodeMCU 1.0)
Set Flash Mode -> DOUT
Leave Upload Speed -> 115200
6) Hold the flash button on the board while uploading the code from the Arduino environment. I suggest the back side of a pencil since you will be holding it a while. Although may work by not foing this
7) Click reset on the board to start the program.
 */
#include <Adafruit_GFX.h>

const char* ssid = "Keenetic-8334";
const char* password = "VaJFhNUn";

ESP8266WebServer server(80);

TFT_eSPI tft = TFT_eSPI();


void handleRoot() {
  server.send(200, "text/html", "<html><body>hello from esp8266!</body></html>");
}

void handleNotFound(){
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
}

void setup()
{
  Serial.begin(115200);
  tft.init();
  tft.fillScreen(TFT_YELLOW);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");

  
  // init done

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  server.on("/", handleRoot);
  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
}

void loop()
{
  server.handleClient();

   int xpos =  0;
  int ypos = 40;

  tft.setTextColor(TFT_YELLOW, TFT_BLACK);
  tft.setCursor(xpos, ypos);    // Set cursor near top left corner of screen

  tft.setTextFont(GLCD);     // Select the orginal small GLCD font by using NULL or GLCD
  tft.println();             // Move cursor down a line
  tft.print("Original GLCD font");    // Print the font name onto the TFT screen
  tft.println();
  tft.println();
}

(deleted)

Flickering is strange.
I never experienced this.
I guess your connections are bad and/or the power supply.
I had several issues with the connections on a breadboard. In the end it never works reliable. Then I used one to one direct connections with dupont wires. And this works perfectly.
Try this.
Best regards,
Chris

(deleted)

(deleted)

The display does not have a backlight control pin.

Not all RPi screens work with the library as they are fitted with different TFT controller chips or different interface circuits.

Hello guys,
I'm new in Arduino, I try to plug a Wemos d1 mini card to a RPI waveshare 3.5 lcd screen. Does anyone know how? I read many post here, but i don't find something for me understand how plug.
Thanks a lot :slight_smile:

post edited as there were some basic questions auto answered.

The previous posts tells a lot to get it working, my only question now is about the touch, I am not sure if I have to wire all touch controller pins apart from CS or they are internally connected to the SPI TFT?

You need to wire the touch controller to the same SPI pins as the display (MOSI, MISO, SCLK) and have different chip select lines.

bodmer:
Ah, sorry. I gave you duff info on how to connect up an ESP8266 board!

These are the connections for the ESP32:

TFT_MISO to ESP32 pin 19
TFT_MOSI to ESP32 pin 23
TFT_SCLK to ESP32 pin 18
TFT_CS to ESP32 pin 15
TFT_DC to ESP32 pin 2
TFT_RST to ESP32 pin 4
TOUCH_CS to ESP32 pin 22

Use the setup file as per post #7 above.

Two GND lines are not necessary but help stop power supply noise from affecting the digital circuit.

@bodmer, based on the pins above, i can conclude u are using VSPI for the ESP32. but seems to be u mix up the pins. MISO, MOSI & SCLK yes u stick with VSPI. but for CS, u are using HSPI pin. should be by right it is IO5 for VSPI ESP32. so i would like to clarify. is it possible for me to change IO15 to IO5?

Yes.

Is possible to have compatibility on esp32 with this it use the ST7796S i think very similar to ili9488. I have ordered 2 pieces and i think i get next week.
Thank's.

Hello, I try to get the 3.5 RPI LCD (A) V3 running, but my screen keeps blank with a ESP8266 nodemcu 0.9.

I have the following pins connected.

esp8266 | RPI board

Vinn 5V
GND GND
D2 CS
D3 DC
D4 RST
V3.3 T_SC

No touchscreen yet till I get a display image.

I use arduino 1.8.12

TFT_ESP 2.2.0 version.

Main question what am I doing wrong here? could somebody help me with this? or what I should change?

I have the following in my in user_setup_select.h
comment this
//#include <User_Setup.h> // Default setup is root library folder

and uncomment this
#include <User_Setups/Setup10_RPi_touch_ILI9486.h> // Setup file configured for ESP8266 and RPi TFT with touch

For the User_setup.h file, I have an attachment from it.

Image from the 3.5 screen also.

User_Setup.h (14 KB)

User_Setup_Select.h (9.35 KB)

The full connections for the setup are:

// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
// Display LED to NodeMCU pin VIN (or 5V, see below)
// Display SCK to NodeMCU pin D5
// Display SDI/MOSI to NodeMCU pin D7
// Display DC (RS/AO)to NodeMCU pin D3
// Display RESET to NodeMCU pin DD (or RST, see below)
// Display CS to NodeMCU pin D8 (or GND, see below)
// Display GND to NodeMCU pin GND (0V)
// Display VCC to NodeMCU 5V or 3.3V

See image here. Note you have defined pin D2 for RST in setup but have wired D4

So I connected this now:

// Display LED to NodeMCU pin VIN (or 5V, see below)
// Display SCK to NodeMCU pin D5
// Display SDI/MOSI to NodeMCU pin D7
// Display DC (RS/AO)to NodeMCU pin D3
// Display RESET to NodeMCU pin D4 (or RST, see below)
// Display CS to NodeMCU pin D8 (or GND, see below)
// Display GND to NodeMCU pin GND (0V)
// Display VCC to NodeMCU 5V or 3.3V

Finally, it has an image.

But now I get washed out screen. Do I miss something? I first thought it was inverted but that is also not the problem. Place some image from test.

Thanks already for the fast response.

Your user setup has multiple driver types enabled. Only define one.

here diagnostic info.

TFT_eSPI ver = 2.2.0
Processor    = ESP33382
Frequency    = 80 MHz
Voltage      = 3.27 V
Transactions = No 
Interface    = SPI 
SPI overlap  = No 

Display driver = 9486
Display width  = 320 
Display height = 480 

TFT_CS   = D8 (GPIO 15)
TFT_DC   = D3 (GPIO 0)
TFT_RST  = D4 (GPIO 2)

TFT_WR   = D2 (GPIO 4)
Font GLCD   loaded
Font 2      loaded
Font 4      loaded
Font 6      loaded
Font 7      loaded
Font 8      loaded
Smooth font enabled

Display SPI frequency = 20.0 MHz

Hi all,
I am trying to get a RPI 3.5" TFT dipsplay to work with an ESP32 using the sSPI library by Bodmer.
The display driver is a ILI9486 and it is the WaveShare SpotPear 3.5inch RPI LCD (A) V3. like tis one

Using the Setup11_RPi_touch_ILI9486.h seems to be the way to go but the display is only rendering an area in one of the corners that looks to be approximately 280x280 pixels (out of 480x320). The colours look to be correct. Some of the sketch examples make the display work within the 280x280 px area and then go crazy outside it. Has anyone encountered this before?
The diagnostics example outputs the following:

TFT_eSPI ver = 2.2.1
Processor    = ESP32
Frequency    = 240MHz
Transactions = Yes
Interface    = SPI
Display driver = 9486
Display width  = 320
Display height = 480
MOSI    = GPIO 2323
MISO    = GPIO 1919
SCK     = GPIO 1818
TFT_CS   = GPIO 15
TFT_DC   = GPIO 2
TFT_RST  = GPIO 4
TOUCH_CS = GPIO 22
Font GLCD   
loaded
Font 2      
loaded
Font 4      
loaded
Font 6      
loaded
Font 7      
loaded
Font 8      
loaded
Smooth 
font enabled


Display SPI frequency = 20.00
Touch SPI frequency   = 2.50

Any advice will be much appreciated.

Shirley your Setup.h would have:

#define RPI_ILI9486_DRIVER // 20MHz maximum SPI

Your report implies that you have the regular ILI9486_DRIVER