by Floris Wouterlood – The Netherlands – May 2, 2021
Introduction
The ESP8266 is a well performing microcontroller chip that is fully Arduino compatible. Its WiFi capability makes boards with this chip easy implementable as IOT devices. Here we wire two representative ESP8266 boards: NodeMCU and Wemos D1 mini to a single-row 14-pin header, 320*240 TFT display that uses the four-wire SPI interface.
figure 1.Wiring diagram: 2.8 inch diagonal 320*240 TFT display and an ESP8266 NodeMCU board.
ILI9143 controlled TFT displays
Here we connect a 320*240 ILI9341 TFT display that has a SPI pin-out. This breakout board has 3.3V controller logic while power supply and background illumination operate on either 3.3V and 5V. ESP8266 microcontroller boards support displays with up to 320*480 pixels
The display shown in figure 1 has a touch screen. It has a single row of 14 pins (figure 1; see also figure 3). The pins supporting ‘touch’ as well as those associated with the SD card reader are not connected: we concentrate on displaying text, variables, graphics and fast sequences of memory-loaded bitmaps (‘image frames”). The ILI9341 controller is fast and, in combination with an ESP8266, performs excellently.
Libraries and pins
The sketch uses the “Adafruit_GFX.h” and “Adafruit_ILI9341.h” libraries. This requires a constructor with defined CS, RST and DC pins. The ‘Clock’ (SCK) pin of the display is connected to pin D5 and the ‘DATA’ (MOSI) pin is wired to pin D7.
The pin connectivity table for the TFT/ESP8266 is as follows (visualized in figures 1, 2 and 3).
TFT | ESP8266 NodeMCU | Wemos D1 mini |
VCC | 3V3 | 5V |
GND | GND | GND |
CS | D2 | D2 |
RST | D3 | D3 |
D/C | D4 | D4 |
SDI (MOSI) | D7 | D7 |
SCK (CLK) | D5 | D5 |
BL | 3V3 | 5V |
The use of the “Adafruit_GFX.h” and “Adafruit_ILI9341.h” libraries makes it necessary to supply a ‘constructor’:
where you can use the previously defined pins or, alternatively, fill in their exact values or their Arduino Uno equivalents:
or the Arduino Uno equivalents for pins D2, D4 and D3:
These three constructors all work!
figure 2. Pin to pin wiring diagram: 2.8 inch diagonal 320*240 TFT display and a ESP8266 Wemos D1 mini microcontroller board.
At work
Figure 3 shows a Wemos D1 mini board mounted on a prototyping breadboard together with a 2.8 inch ILI9341 SPI TFT display according to the wiring diagram shown in Figure 2. The ESP8266 is running a demo adapted for the “Adafruit_GFX.h” and “Adafruit_ILI9341.h” libraries from Bodmer’s ‘Clock’ example for his TFT_eSPI library.
figure 3: Wemos D1 mini running Bodmer’s Clock example on an ILI9341 TFT display.
Downloadable sketches
There are two sketches:
• ESP8266_ILI9341_Adafruit_demo.ini: the well known Adafruit repertoire of graphic tests that illustrate the performance of the display.
• ESP8266_ILI9341_Adafruit_Bodmers_clock.ino, a real time analog clock example adapted from Bodmer’s TFT_eSPi library examples (display visible in figure 3).
sketches are packed in a ZIP file: ESP8266_ILI9341_Adafruit_demo_Bodmers_clock_demo.zip