Skip to content
Fit-Out Quote Configure Your Studio Bundle

What library supports a 2.4 inch IPS LCD in Arduino?

·  About the author

If you’re working with a 2.4 inch 240x320 ips display that uses an SPI interface (common driver chips like ILI9341, ST7789, or ILI9488), the most widely supported library in the Arduino ecosystem is the Adafruit_ILI9341 library, combined with the Adafruit_GFX library for graphics primitives. However, the exact library depends on the specific driver chip your display uses. For a 2.4-inch IPS LCD with a 240x320 resolution and SPI interface, the ILI9341 driver is the most common, and Adafruit’s library is the de facto standard. But let’s break this down with real data, hardware specifics, and alternative libraries so you can choose the right one for your project.

Hardware and driver chip specifics

Most 2.4-inch IPS LCDs sold for Arduino use the ILI9341 driver, which supports 262K colors and a 240x320 pixel resolution. The SPI interface typically uses 4 wires: MOSI, MISO, SCLK, and CS (chip select), plus DC (data/command) and RST (reset). Some modules also include a touch controller (like the XPT2046) over SPI. The Adafruit_ILI9341 library is optimized for these displays and works with Arduino boards like the Uno, Mega, ESP32, and STM32. It supports hardware SPI (faster) and software SPI (flexible pin assignment). For example, on an Arduino Uno, hardware SPI uses pins 11 (MOSI), 12 (MISO), and 13 (SCLK), while you can set CS, DC, and RST to any digital pins. The library handles initialization, pixel drawing, and color management. The 2.4 inch 240x320 ips display from DisplayModule, for instance, uses the ILI9341 driver and is fully compatible with this library.

Alternative libraries and their strengths

If your display uses a different driver, such as the ST7789 (common in some 2.4-inch IPS modules) or ILI9488 (for 480x320 resolution), you’ll need a different library. The TFT_eSPI library by Bodmer is a high-performance alternative that supports ILI9341, ST7789, ST7735, and many others. It’s particularly popular on ESP32 boards because it uses DMA (Direct Memory Access) for faster frame rates. For example, with an ESP32 and TFT_eSPI, you can achieve 60+ FPS for simple animations, compared to 20-30 FPS with Adafruit libraries on the same hardware. TFT_eSPI also supports custom pin configurations and SPI clock speeds up to 80 MHz on ESP32, while Adafruit_ILI9341 typically caps at 40 MHz on 8-bit boards. Another option is the MCUFRIEND_kbv library, which auto-detects the driver chip and works with many generic 2.4-inch displays. It’s less optimized but great for beginners because it includes example code for touch calibration and rotation.

Performance benchmarks and data

To give you a concrete idea of performance, let’s look at benchmark data. Using an Arduino Uno at 16 MHz, the Adafruit_ILI9341 library with hardware SPI can fill a 240x320 screen in about 320 milliseconds (roughly 3 FPS for full-screen updates). On an ESP32 at 240 MHz, the same library achieves 40-50 ms per full-screen fill (20-25 FPS). With TFT_eSPI on an ESP32, full-screen fills drop to 10-15 ms (60-80 FPS) due to DMA and optimized SPI transactions. For text rendering, Adafruit_GFX draws a single character in about 0.5 ms on an Uno, while TFT_eSPI’s font rendering is 2-3x faster because it uses pre-rendered bitmaps. If you’re building a UI with frequent updates (like a game or data dashboard), TFT_eSPI is the better choice. For static displays or simple text, Adafruit_ILI9341 is sufficient and easier to set up.

Pin compatibility and wiring

Most 2.4-inch IPS modules use a 8-pin or 14-pin header. The 8-pin version typically includes: VCC (3.3V or 5V), GND, CS, RST, DC, MOSI, MISO, and SCLK. Some modules also have a backlight pin (LED) and a touch controller (T_IRQ, T_DO, T_DIN, T_CS). The Adafruit_ILI9341 library expects the following connections (example for Arduino Uno):

- VCC → 3.3V (or 5V if your module has a voltage regulator)
- GND → GND
- CS → Digital pin 10
- RST → Digital pin 9
- DC → Digital pin 8
- MOSI → Digital pin 11 (hardware SPI)
- MISO → Digital pin 12 (hardware SPI)
- SCLK → Digital pin 13 (hardware SPI)
- LED → 3.3V (or PWM pin for brightness control)

If your display uses a ST7789 driver, the pinout is identical, but you’ll need the Adafruit_ST7789 library or TFT_eSPI. For ILI9488, which uses 8-bit parallel or SPI, the Adafruit_ILI9488 library works, but it’s slower than TFT_eSPI. Always check the datasheet or communicate with the seller to confirm the driver chip. The 2.4 inch 240x320 ips display from DisplayModule explicitly lists ILI9341 as the driver, so you’re safe with Adafruit_ILI9341.

Touch integration and calibration

Many 2.4-inch IPS modules include a resistive touch panel. The touch controller is usually an XPT2046, which communicates over SPI. The Adafruit_TouchScreen library works with this controller, but it requires calibration because resistive touch coordinates don’t map directly to pixel coordinates. A typical calibration routine involves reading four corners of the touch panel and computing a linear transformation matrix. For example, with an Arduino Uno, the touch library reads X and Y values as 12-bit integers (0-4095). You then map these to 240x320 using min/max values from calibration. The TFT_eSPI library includes a built-in touch calibration example that outputs a header file with the calibration constants. If you’re using the MCUFRIEND_kbv library, it also has a calibration sketch that prints the constants to the serial monitor. Without calibration, touch coordinates will be offset or inverted, so this step is mandatory for any interactive project.

Memory and RAM considerations

Arduino boards have limited RAM, which affects what you can do with a 2.4-inch display. An Arduino Uno has only 2 KB of SRAM. The Adafruit_ILI9341 library allocates a 320-byte framebuffer for SPI transactions (not a full frame buffer), so it’s memory-efficient. However, drawing complex shapes or images requires storing data in PROGMEM (flash memory) or using SD cards. TFT_eSPI on an ESP32 can use a 320x240x16-bit framebuffer (150 KB), which is feasible because ESP32 has 520 KB SRAM. This allows double-buffering for smooth animations. On an Uno, you’re limited to drawing primitives directly to the screen without a buffer. If you need to display images, use the JPEGDecoder library or the SD library to read bitmap files from an SD card. The Adafruit_ImageReader library works with Adafruit_ILI9341 and supports BMP, GIF, and JPEG formats, but it requires a lot of flash memory for the code (about 20 KB).

Power consumption and voltage levels

2.4-inch IPS displays typically consume 80-150 mA at 3.3V, depending on brightness and content. The backlight LED draws 20-50 mA alone. If you’re running on battery power, consider using a PWM pin to dim the backlight (e.g., 50% duty cycle reduces current to 30-60 mA). The display logic operates at 3.3V, but many modules include a 5V-tolerant regulator for VCC. However, data pins (MOSI, MISO, SCLK) must be 3.3V logic levels. If you’re using a 5V Arduino board like the Uno, use a level shifter (e.g., 74LVC245) or voltage divider resistors to avoid damaging the display. Some modules, like the one from DisplayModule, have built-in level shifting for 5V logic, but always verify the datasheet. The Adafruit_ILI9341 library includes a setRotation() function that changes the orientation (0, 1, 2, 3) and adjusts the coordinate system accordingly. This is useful for mounting the display in portrait or landscape mode.

Software setup and code example

Here’s a minimal working example using the Adafruit_ILI9341 library on an Arduino Uno. Install the library via the Arduino Library Manager (search for “Adafruit ILI9341” and “Adafruit GFX”). Wire the display as described above, then upload this code:

#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(9600);
tft.begin();
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("Hello, World!");
}
void loop() {}

This code initializes the display, clears the screen to black, and prints “Hello, World!” in white text. The begin() function automatically detects the SPI speed and initializes the driver. If you’re using an ESP32, you can set custom SPI pins using Adafruit_ILI9341(tft_CS, tft_DC, tft_MOSI, tft_SCLK, tft_RST, tft_MISO). The library also supports drawPixel(), drawLine(), drawRect(), and fillRect() for basic shapes. For more advanced graphics, the Adafruit_GFX library provides functions like drawCircle(), drawTriangle(), and drawRoundRect().

Common issues and troubleshooting

If the display shows nothing or garbled data, check the wiring first—especially the CS, DC, and RST pins. Many users forget to connect the RST pin to a digital pin or to 3.3V (which disables reset). The begin() function in Adafruit_ILI9341 toggles RST low and high, so it must be connected. If you’re using software SPI (by passing all 6 pins to the constructor), ensure the pins are digital-capable (e.g., pins 0 and 1 are used for serial communication on Uno). Another common issue is the SPI clock speed. On an Uno, the default SPI speed is 4 MHz, which is fine for ILI9341. On an ESP32, the library defaults to 40 MHz, but some modules can’t handle that speed—try reducing it with tft.begin(SPI_CLOCK_DIV4) (which sets 10 MHz on ESP32). If the display shows incorrect colors, you might have a 16-bit or 18-bit color mode mismatch. The ILI9341 supports both, but Adafruit_ILI9341 defaults to 16-bit (RGB565). If your module expects 18-bit, you’ll see color banding. You can change the color mode by editing the library’s header file, but it’s easier to just use the TFT_eSPI library, which auto-detects the color depth.

Real-world project examples

For a weather station, you can use the Adafruit_ILI9341 library to display temperature, humidity, and pressure data from a BME280 sensor. The library’s setCursor() and print() functions make it easy to position text. For a game like Tetris, TFT_eSPI’s fast pixel drawing is essential for smooth block movement. The drawFastVLine() and drawFastHLine() functions in Adafruit_GFX are optimized for vertical and horizontal lines, which are common in grid-based games. If you’re building a menu system, use the fillRect() function to create buttons and the drawRoundRect() for rounded corners. The setTextColor() function supports a background color parameter, so you can draw text over existing graphics without clearing the screen. For example, tft.setTextColor(ILI9341_WHITE, ILI9341_BLUE) draws white text on a blue background.

Library comparison table

Here’s a quick comparison of the three main libraries for 2.4-inch IPS displays:

- Adafruit_ILI9341 + Adafruit_GFX: Best for beginners, stable, excellent documentation, supports ILI9341 only, max SPI speed 40 MHz on Uno, 20-30 FPS on ESP32, memory usage ~2 KB SRAM on Uno.
- TFT_eSPI: Best for performance, supports ILI9341, ST7789, ILI9488, and others, 60-80 FPS on ESP32, supports DMA and custom fonts, memory usage ~150 KB for framebuffer on ESP32, requires manual configuration of pins and driver in user_setup.h.
- MCUFRIEND_kbv: Best for auto-detection, supports many generic displays, includes touch calibration, slower than TFT_eSPI, memory usage ~3 KB SRAM on Uno, limited documentation but active community.

For the 2.4 inch 240x320 ips display from DisplayModule, Adafruit_ILI9341 is the safest choice if you’re using an Arduino Uno or Mega. If you’re on an ESP32 and need high frame rates, switch to TFT_eSPI. The MCUFRIEND_kbv library is a good fallback if you’re unsure about the driver chip.

Advanced features: SPI vs 8-bit parallel

Some 2.4-inch IPS modules support both SPI and 8-bit parallel interfaces. The parallel interface uses 8 data pins (D0-D7) plus WR, RD, and CS, which can double the frame rate but uses more GPIO pins. On an Arduino Uno, you don’t have enough pins for parallel (you’d need 13+ pins), so SPI is the only option. On an Arduino Mega, you can use the Adafruit_ILI9341 library with parallel mode by specifying the 8-bit data port (e.g., PORTF). However, the library’s parallel support is experimental and not well documented. The TFT_eSPI library also supports parallel mode for ILI9488, but it’s complex to set up. For most projects, SPI is sufficient and simpler. The 2.4 inch 240x320 ips display from DisplayModule uses SPI only, so you don’t need to worry about parallel mode.

Color depth and gamma correction

The ILI9341 driver supports 16-bit (RGB565) and 18-bit (RGB666) color modes. The Adafruit_ILI9341 library uses 16-bit by default, which gives 65,536 colors. This is fine for most applications, but if you need more accurate color reproduction (e.g., for photo display), you can switch to 18-bit mode by modifying the library’s initialization sequence. However, SPI bandwidth becomes a bottleneck—18-bit mode requires 3 bytes per pixel instead of 2, reducing frame rate by 33%. The TFT_eSPI library supports both modes and automatically selects the best one based on the driver. Gamma correction is handled by the ILI9341’s internal registers, which you can adjust using the writeCommand() and spiWrite() functions. The default gamma curve is linear, but you can apply a custom curve for better contrast. This is an advanced topic and rarely needed for typical Arduino projects.

SD card and image display

Many 2.4-inch IPS modules include a microSD card slot that shares the SPI bus with the display. The SD card uses a separate CS pin (usually pin 4 on the

About the author

admin

Writes from the Rotterdam studio on color science, projection hardware, and the installations that put them to work.

Continue reading

Projectors

The factory-calibrated line, ΔE<1 out of the box.

Installations

312 institutions, four continents, one color pipeline.