The 2.8" ILI9341 TFT is the step up from small OLEDs: a 320 × 240 colour screen big enough for a real user interface, with a resistive touch panel on top and usually a microSD slot on the back, all for a few dollars. It talks over SPI, so it needs only a handful of pins, and the ILI9341 driver chip holds the whole image in its own memory, so your microcontroller only sends what changes.
The common red module is a 3.3 V logic device. That one fact decides how you wire it: an ESP32 connects directly, while a 5 V Arduino Uno needs level shifting on its outputs. This page explains the pinout, the voltage question, the three devices that share its SPI bus (display, touch, SD card), speed and memory limits, and which library to use. For code, see the Arduino Uno guide and the ESP32 guide.
ILI9341 in one paragraph. 2.8", 320 × 240, 16-bit colour over SPI, XPT2046 resistive touch on the same bus with its own CS pin, microSD on the back. Power VCC from 5 V or 3.3 V (see the J1 jumper), but logic pins are 3.3 V: wire an ESP32 directly; on an Uno use a level shifter or resistor dividers on CS, DC, RST, MOSI and SCK. On ESP32 use TFT_eSPI for speed; on an Uno use Adafruit_ILI9341.
Which ILI9341 module do you have?
Several different boards are sold as "2.8 inch ILI9341", and they are not wired the same way. Check yours before you follow any tutorial.
| Module | How to recognise it | What changes |
|---|---|---|
| Red SPI module (this page) | Red PCB, 14-pin header on one edge, 4-pin SD header on the other, J1 jumper | 3.3 V logic, no level shifter. Wire as on this page |
| 8-bit parallel Uno shield | Plugs straight onto an Uno, uses most of its pins, no SPI header | Not SPI at all. The driver chip varies between batches; use the MCUFRIEND_kbv library, which identifies it |
| Branded breakout (Adafruit and similar) | Pins labelled for SPI and parallel, built-in level shifting | Safe on 5 V boards without a buffer. Some versions have capacitive touch (FT6206) instead of the XPT2046 |
| 2.4" or 3.2" SPI module | Same 14-pin header, different screen size | Same ILI9341 driver and the same code; only the size differs |
Specifications
- Display
- 2.8" TFT, 320 × 240 pixels (QVGA), transmissive
- Driver chip
- ILI9341 with 172,800 bytes of built-in frame memory
- Colour
- 16-bit RGB565 (65,536 colours) over SPI; the chip also supports 18-bit
- Interface
- 4-wire SPI: SCK, MOSI, MISO (optional), CS, plus DC and RESET
- SPI clock
- 10 MHz in the datasheet; 27 to 40 MHz works on most modules in practice
- Touch
- 4-wire resistive panel, XPT2046 12-bit controller on SPI (2.5 MHz clock maximum)
- Storage
- microSD slot on its own 4-pin header (SPI)
- Module supply
- 5 V or 3.3 V on VCC: onboard 3.3 V regulator; short J1 to bypass it at 3.3 V
- Logic level
- 3.3 V. The common red module has no level shifter
- Current
- About 0.31 W (LCDwiki MSP2807 spec), roughly 60 mA at 5 V
- Backlight
- LED pin, active HIGH: tie it to 3.3 V for always on
- Active area
- 43.2 × 57.6 mm; module about 50 × 86 mm
Figures for the common red 2.8" SPI module (often marked TJCTM24028-SPI) and the ILI9341 / XPT2046 datasheets. Branded breakouts, such as Adafruit's, add level shifting and may use other pin names.
Pinout (14-pin header)
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Module power, 5 V or 3.3 V (see J1) |
| 2 | GND | Ground |
| 3 | CS | Display chip select, active LOW |
| 4 | RESET | Display reset, active LOW. Can be tied to 3.3 V if you are short of pins |
| 5 | DC / RS | Data / command select: LOW = command, HIGH = pixel data |
| 6 | SDI (MOSI) | SPI data into the display |
| 7 | SCK | SPI clock |
| 8 | LED | Backlight. 3.3 V for always on, or a GPIO / PWM pin for on-off and dimming |
| 9 | SDO (MISO) | SPI data out of the display. Only needed to read back from it; leave it off if it upsets other SPI devices |
| 10 | T_CLK | Touch SPI clock: join to SCK |
| 11 | T_CS | Touch chip select, active LOW |
| 12 | T_DIN | Touch data in: join to MOSI |
| 13 | T_DO | Touch data out: join to MISO |
| 14 | T_IRQ | Goes LOW while the screen is touched (optional) |
The separate 4-pin header on the other edge is the SD card: SD_CS, SD_MOSI, SD_MISO, SD_SCK.
The voltage question: 5 V power, 3.3 V logic
The module has a 3.3 V regulator, so VCC can take 5 V. That regulator powers the display and touch chips, but it does nothing for the signal pins. On the common red module the logic inputs connect straight to the 3.3 V chips: there is no level shifter. Some sellers' listings say otherwise; check yours.
- ESP32, ESP8266, Pico, STM32 (3.3 V boards): wire directly. Power VCC from 3.3 V or 5 V.
- Arduino Uno, Nano, Mega (5 V boards): put a level shifter or resistor dividers on every pin the Arduino drives: CS, DC, RESET, MOSI and SCK, and T_CS if you use touch. Signals coming back (MISO, T_DO, T_IRQ) are 3.3 V and the Uno reads them as HIGH without help.
Driving the logic pins straight from 5 V often seems to work, with a white screen or corrupted colours as the warning signs, and stresses the chip's input protection. A 4050-type buffer (CD4050 / 74HC4050) powered at 3.3 V, or a 1 kΩ / 2 kΩ divider per line, fixes it.
J1 jumper: leave it open when VCC is 5 V. Short it only when you supply 3.3 V and want to bypass the regulator's dropout.
Three devices, one SPI bus
The module carries three SPI devices: the display, the touch controller and the SD card. They share the clock and data lines and each has its own chip-select. Only the device whose CS is LOW listens, so the rule is simple: every CS gets its own pin, and every unused CS is held HIGH. A floating T_CS or SD_CS is the most common reason the display works on its own and fails once touch or SD is added.
The touch controller is slow (its datasheet allows a 2.5 MHz clock at most) while the display is happy at 27 to 40 MHz; the libraries handle this by changing the SPI speed for each transaction. New to SPI? I2C vs SPI explains how chip-select works.
Speed and memory: what to expect
SPI clock
- Arduino Uno
- 8 MHz maximum (half the 16 MHz CPU clock)
- ESP32
- 27 to 40 MHz with TFT_eSPI
Full-screen colour fill
- Arduino Uno
- At least 154 ms at 8 MHz (pixel data alone); slower in practice, you can watch it sweep
- ESP32
- At least 31 ms at 40 MHz
RAM for a full-screen buffer (150 KB)
- Arduino Uno
- Impossible (2 KB of RAM)
- ESP32
- Rarely possible without PSRAM; use partial sprites
Images from SD card
- Arduino Uno
- Slow but workable for occasional photos
- ESP32
- Fast enough for a picture viewer
Best library
- Arduino Uno
- Adafruit_ILI9341 + Adafruit GFX
- ESP32
- TFT_eSPI (or Adafruit_ILI9341 for portability)
Timings are typical for the libraries named; your numbers depend on the SPI clock and what you draw.
Draw what changed, not the whole screen. The display keeps its own image, so the fastest code redraws only the region that changed: print a number over a filled rectangle the size of the old text, or, on the ESP32, render a small sprite in RAM and push it in one go. Both board guides include a flicker-free example.
Ready to build?
- ILI9341 with Arduino Uno: level-shifted wiring, a graphics test, a touch paint sketch with calibration, and a flicker-free live value display
- ILI9341 with ESP32: direct wiring, TFT_eSPI setup step by step, touch buttons with built-in calibration, and a smooth sprite-based gauge
Troubleshooting
White screen, backlight on
- Likely cause
- No valid SPI data: wrong pins, wrong driver selected, or 5 V logic on a 3.3 V module
- Fix
- Check CS/DC/RST in the sketch, select ILI9341 in TFT_eSPI, add level shifting on 5 V boards
Black screen
- Likely cause
- Backlight off
- Fix
- Connect LED to 3.3 V, or set its GPIO HIGH
Garbled or shifted image
- Likely cause
- SPI clock too fast for your wiring
- Fix
- Shorten wires, or lower the SPI frequency (27 MHz instead of 40)
Colours wrong (red and blue swapped)
- Likely cause
- Different panel variant or wrong colour order setting
- Fix
- Set TFT_RGB_ORDER in TFT_eSPI, or try tft.invertDisplay()
Display works, touch does not
- Likely cause
- T_CS floating or wrong pin, or touch on a different bus
- Fix
- Give T_CS its own pin, join T_CLK/T_DIN/T_DO to SCK/MOSI/MISO
Touch reports the wrong position
- Likely cause
- Not calibrated, or rotation differs from the display
- Fix
- Run the calibration step and use the same rotation for both
Display stops when the SD card is used
- Likely cause
- SD_CS floating, or MISO conflict
- Fix
- Hold every unused CS HIGH; disconnect the display's SDO if it holds MISO
Frequently asked questions
Does the ILI9341 work with 5 V Arduinos? Yes, with level shifting on the signal lines. VCC can be 5 V; the logic pins must see 3.3 V. Branded breakouts with built-in level shifters (for example Adafruit's) can be wired directly; the common red module cannot.
Which library should I use?
On an ESP32, TFT_eSPI by Bodmer: it is several times faster and includes touch support and sprites, but it is configured through a setup file. On an Uno, Adafruit_ILI9341 with Adafruit GFX: it works out of the box. Both use the familiar print, drawLine and fillRect style.
Is the touch screen capacitive? No, it is resistive: you press it, and a stylus works best. It needs calibration and is less precise than a phone screen, but it works with gloves and costs almost nothing.
Can I use the microSD slot? Yes. It has its own 4-pin header (SD_CS, SD_MOSI, SD_MISO, SD_SCK) that joins the same SPI bus with its own chip-select. On a 5 V board the SD lines need level shifting too; the card is a 3.3 V device.
Can it show photos? Yes. Store BMP or JPEG files on the microSD card; TFT_eSPI with the TJpg_Decoder library decodes JPEG on an ESP32. On an Uno, stick to small BMPs.
ILI9341 or ST7789? The ST7789 1.3" is smaller, sharper per inch and has no touch. Choose the ILI9341 when you want a larger screen or touch input. For simple text and numbers, a 0.96" SSD1306 OLED is cheaper and needs only two I²C wires.
Can I dim the backlight? The LED pin is active HIGH: 3.3 V turns the backlight fully on. To switch or dim it, drive LED from a GPIO with PWM, but measure the current it draws on your board first; if it is more than a GPIO should supply, switch it through a small NPN transistor or MOSFET instead.
Sources
- LCDwiki: 2.8inch SPI Module ILI9341 (MSP2807): header order, 3.3 V logic, VCC 3.3 to 5 V, 0.31 W, 50 × 86 mm PCB, 43.2 × 57.6 mm active area
- ILI9341 datasheet: serial interface timing and the 172,800-byte frame memory
- TI CD4050B datasheet: buffer pin numbers used in the Uno wiring
- Redraw times are calculated: 320 × 240 pixels × 16 bits ÷ SPI clock, pixel data only
Wiring & code
Board integration
Library
Adafruit_ILI9341 by Adafruit
Library Manager: install "Adafruit ILI9341" (with Adafruit GFX Library and Adafruit BusIO), plus "XPT2046_Touchscreen" by Paul Stoffregen for touch
This guide runs the 2.8" ILI9341 touchscreen from an Arduino Uno. Because the Uno is a 5 V board and the display's logic is 3.3 V, the wiring goes through a level shifter; everything else is plug-and-play with the Adafruit libraries. You will run a graphics test, build a touch paint sketch with calibration, and learn the flicker-free way to show changing numbers, which matters on the Uno's 8 MHz SPI. Pinout and background are on the ILI9341 overview.
What you need
1Arduino Uno R3 (or Nano)
- Notes
- The Mega works too; its SPI pins are 50 to 53
12.8" ILI9341 SPI TFT with touch
- Notes
- The common red module
1CD4050 or 74HC4050 hex buffer
- Notes
- Level shifter powered from 3.3 V. Or six 1 kΩ / 2 kΩ divider pairs
1Breadboard and jumper wires
- Notes
- Keep SPI wires under about 15 cm
110 kΩ potentiometer (optional)
- Notes
- For the live value sketch, on A0
Wiring: ILI9341 to Arduino Uno
| Display pin | Uno pin | Through the level shifter? |
|---|---|---|
| VCC | 5V | No (J1 open) |
| GND | GND | No |
| CS | D10 | Yes |
| RESET | D8 | Yes |
| DC / RS | D9 | Yes |
| SDI (MOSI) | D11 | Yes |
| SCK | D13 | Yes |
| LED | 3.3V | No (always on) |
| SDO (MISO) | D12 | No: 3.3 V into the Uno is read as HIGH |
| T_CLK | D13 (with SCK) | Yes, same buffered line as SCK |
| T_CS | D4 | Yes |
| T_DIN | D11 (with MOSI) | Yes, same buffered line as MOSI |
| T_DO | D12 (with MISO) | No |
| T_IRQ | D3 | No (optional) |
Wiring the CD4050. Power its pin 1 from the Uno's 3.3V pin and pin 8 from GND. Each buffer has an input and an output: feed the Uno's D8, D9, D10, D11, D13 and D4 into six inputs, and take the six outputs to RESET, DC, CS, MOSI/T_DIN, SCK/T_CLK and T_CS. Because the CD4050 runs from 3.3 V, its outputs are 3.3 V even though its inputs accept 5 V. That uses all six buffers; if you add the SD card later, its SD_CS, SD_MOSI and SD_SCK lines need a second CD4050.
Using dividers instead? A 1 kΩ (from the Uno pin) and 2 kΩ (to GND) pair per line works. It can round off the SPI edges at higher speeds; if the image is garbled, shorten the wires or switch to the buffer.
Install the libraries
- 1Sketch > Include Library > Manage Libraries.
- 2Install "Adafruit ILI9341" and accept its dependencies "Adafruit GFX Library" and "Adafruit BusIO".
- 3Install "XPT2046_Touchscreen" by Paul Stoffregen for the touch sketches.
Sketch 1 - Graphics test
Text in three sizes, lines, a filled circle and a rounded rectangle: if all of these appear with the right colours, the wiring and level shifting are good.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
Adafruit_ILI9341 tft(TFT_CS, TFT_DC, TFT_RST); // hardware SPI on D11 / D13
void setup() {
pinMode(4, OUTPUT);
digitalWrite(4, HIGH); // touch CS high, so it ignores display traffic
tft.begin();
tft.setRotation(1); // 0-3: 1 = landscape, 320 x 240
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);
tft.setCursor(10, 10);
tft.println("SolderHub");
tft.setTextSize(2);
tft.setTextColor(ILI9341_YELLOW);
tft.println(" ILI9341 on an Uno");
tft.drawLine(0, 80, 319, 80, ILI9341_CYAN);
tft.fillCircle(70, 160, 45, ILI9341_RED);
tft.fillRoundRect(150, 115, 150, 90, 12, ILI9341_BLUE);
tft.setCursor(170, 150);
tft.setTextColor(ILI9341_WHITE);
tft.print("320x240");
}
void loop() {}How Sketch 1 works
| Call | What it does |
|---|---|
| Adafruit_ILI9341 tft(CS, DC, RST) | Uses the Uno's hardware SPI (D11 MOSI, D13 SCK) plus three control pins |
| digitalWrite(4, HIGH) | Parks the touch controller's CS so it ignores display traffic |
| tft.begin() | Resets the panel and sends the ILI9341 start-up sequence |
| setRotation(1) | Landscape. 0 and 2 are portrait (240 × 320), 1 and 3 landscape |
| fillScreen / fillRect | Writes every pixel in the area: the slow part on an Uno, so use it sparingly |
| setTextSize(n) | Scales the built-in 6 × 8 font; size 2 is 12 × 16 pixels per character |
| Colours (ILI9341_RED...) | 16-bit RGB565 values; tft.color565(r, g, b) makes your own |
Sketch 2 - Touch paint with calibration
The resistive panel reports raw numbers, roughly 200 to 3900 on each axis, not pixels. This sketch maps them to screen coordinates and draws a dot wherever you press. First run it as is and press the four corners: the Serial Monitor prints the raw values. Put the smallest and largest you see into the four constants, upload again, and the dots land under your stylus.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <XPT2046_Touchscreen.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
#define TOUCH_CS 4
// Raw touch range: replace with the values your corners print
const int RAW_X_MIN = 300, RAW_X_MAX = 3800;
const int RAW_Y_MIN = 300, RAW_Y_MAX = 3800;
Adafruit_ILI9341 tft(TFT_CS, TFT_DC, TFT_RST);
XPT2046_Touchscreen ts(TOUCH_CS);
void setup() {
Serial.begin(9600);
tft.begin();
tft.setRotation(1);
ts.begin();
ts.setRotation(1); // keep touch and display rotations the same
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(5, 5);
tft.print("Draw with a stylus. Tap top-left to clear.");
}
void loop() {
if (!ts.touched()) return;
TS_Point p = ts.getPoint(); // raw x, y and pressure z
int x = constrain(map(p.x, RAW_X_MIN, RAW_X_MAX, 0, 319), 0, 319);
int y = constrain(map(p.y, RAW_Y_MIN, RAW_Y_MAX, 0, 239), 0, 239);
Serial.print("raw "); Serial.print(p.x); Serial.print(", "); Serial.print(p.y);
Serial.print(" -> "); Serial.print(x); Serial.print(", "); Serial.println(y);
if (x < 30 && y < 30) { // corner tap clears the canvas
tft.fillScreen(ILI9341_BLACK);
delay(300);
return;
}
tft.fillCircle(x, y, 3, ILI9341_GREEN);
}Tip
If strokes appear mirrored, swap RAW_X_MIN and RAW_X_MAX (or the Y pair). If X moves when you move vertically, the axes are swapped: try another ts.setRotation() value until the dot follows the stylus.
Sketch 3 - Flicker-free live value
Clearing the screen and redrawing everything every loop makes an Uno-driven TFT flash badly, because a full fill takes about 0.2 to 0.3 s. The fix: draw the labels once in setup(), then in loop() update only the number and the bar, and only when the value has changed. Text drawn with a background colour overwrites the old digits in one pass.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
Adafruit_ILI9341 tft(TFT_CS, TFT_DC, TFT_RST);
int lastValue = -1;
void setup() {
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_CYAN);
tft.setTextSize(2);
tft.setCursor(20, 20);
tft.print("Potentiometer on A0");
tft.drawRect(19, 149, 282, 32, ILI9341_WHITE); // bar outline, drawn once
}
void loop() {
int value = analogRead(A0) / 4; // 0-255, ignores tiny jitter
if (value == lastValue) return; // nothing changed: draw nothing
lastValue = value;
// Number: the background colour erases the old digits as it draws
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
tft.setTextSize(6);
tft.setCursor(20, 60);
char buf[5];
snprintf(buf, sizeof(buf), "%3d", value); // fixed width: no leftovers
tft.print(buf);
// Bar: fill the new part, clear the rest
int w = map(value, 0, 255, 0, 280);
tft.fillRect(20, 150, w, 30, ILI9341_GREEN);
tft.fillRect(20 + w, 150, 280 - w, 30, ILI9341_BLACK);
}Troubleshooting on the Uno
White screen
- Likely cause
- Logic not level-shifted, or CS/DC/RST pins differ from the sketch
- Fix
- Check the buffer is powered from 3.3 V and the pin numbers match
Works for a while, then white or garbled
- Likely cause
- Marginal levels or long wires
- Fix
- Use the CD4050 rather than dividers; keep wires short
Touch never registers
- Likely cause
- T_CS not on D4, or T_DO not joined to MISO (D12)
- Fix
- Check the touch lines join the SPI bus as in the table
Sketch does not fit or behaves randomly
- Likely cause
- Low RAM: GFX fonts and SD libraries use a lot
- Fix
- Avoid large custom fonts; check the free-memory figure the IDE reports
SD card fails once the display runs
- Likely cause
- SD card also needs 3.3 V logic and its own CS
- Fix
- Level-shift SD_CS, SD_MOSI and SD_SCK too, and hold unused CS lines HIGH
Arduino Uno FAQ
Can I skip the level shifter? Many people do and the display often works, but you are driving 3.3 V inputs with 5 V and relying on the chip's protection diodes. Expect white screens and a shorter life. The buffer costs less than the display.
Why is it so slow compared with videos I have seen? Those are usually ESP32s. The Uno's SPI tops out at 8 MHz and it has no RAM for a frame buffer, so full-screen redraws take a visible fraction of a second. Partial updates, as in Sketch 3, make it feel quick.
Does this work on the Mega? Yes, with SPI on pins 51 (MOSI), 52 (SCK) and 50 (MISO), and the same level shifting. The Mega's extra RAM helps with fonts and SD images.
Where next? The ILI9341 ESP32 guide shows the same screen running several times faster, or compare with the smaller ST7789 1.3" display.
