I recently got a Adafruit TFT screen and an ESP-32 development kit. I was trying to interface these two the pin connections I used areas follows:
TFT | ESP-32
------+----------
3V3 | Vcc
Gnd | Gnd
MOSI | GPIO19
SCK | GPIO18
CS | GPIO5
D/C | GPIO16
RST | GPIO 17
I used this library: https://github.com/MartyMacGyver/ESP32_Adafruit_ILI9341
The SPI library used was the one that comes while installing Arduino support for ESP-32.
The code compiles and uploads without any error/ warning but the TFT screen does not show any response (except powering up).
This is the code I used for testing:
//#include <Adafruit_ST7735.h>
#include<Adafruit_ILI9341.h>
#include <Adafruit_GFX.h>
#include "SPI.h"
#define TFT_CS 5
#define TFT_RST 17
#define TFT_DC 16
// 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, 23, 18, TFT_RST);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("In the setup.");
//tft.initR(INITR_BLACKTAB);
unsigned long t=micros();
tft.fillScreen(ILI9341_RED);
Serial.println(micros()-t);
}
void loop() {
// put your main code here, to run repeatedly:
}
The code compiles and uploads without any error/warning but the TFT screen does not show any response (except powering up).
NOTE: The library works fine with Arduino Mega and TFT display.
-
2MOSI and SCK both on GPIO19...?Majenko– Majenko2017年04月15日 20:32:13 +00:00Commented Apr 15, 2017 at 20:32
-
I have now corrected the discription of connections sck is at pin 18 not 19.Harsh Chittora– Harsh Chittora2017年04月16日 06:00:04 +00:00Commented Apr 16, 2017 at 6:00
-
Why have you commented out the TFT initialisation function?Majenko– Majenko2017年04月16日 07:59:11 +00:00Commented Apr 16, 2017 at 7:59
-
1That instantiates the object, it doesn't initialise the TFT. I repeat: why have you commented out the initialisation function?Majenko– Majenko2017年04月16日 08:26:52 +00:00Commented Apr 16, 2017 at 8:26
-
3Also why tell the library MOSI is on 23 when it is on 19?Majenko– Majenko2017年04月16日 08:29:28 +00:00Commented Apr 16, 2017 at 8:29
1 Answer 1
Ok, sorry for the delay, I had my exams. But I have finally solved the issue. There were several issues:
- MOSI should be connected to pin 23 not 19.
tft.begin()
function should be in the setup to initialize the TFT. (for ILI9341)- The SPI library used should be the one that comes with ESP-32 support. The general SPI library for Arduino does not work with ESP-32.
Note: the ST7735 library currently does not work with ESP-32. It can be made to work by adding the following definitions given bellow to the Adafruit_ST7735.h header file.
#elif defined(ESP32)
volatile uint32_t *dataport, *clkport, *csport, *rsport;
uint32_t _cs, _rs, _rst, _sid, _sclk,
datapinmask, clkpinmask, cspinmask, rspinmask,
colstart, rowstart;
(add this just after the ESP8266 definitions).