Skip to content

How to use a 1.14 inch IPS screen with ESP32?

aadmin· · By the NDAGLinks editors

To use a 1.14 inch IPS screen with an ESP32, you need to connect the display via SPI interface, configure the microcontroller's GPIO pins, and load a compatible graphics library like Adafruit ST7789 or TFT_eSPI. The specific model, a 1.14 inch 240x135 ips display, uses the ST7789V driver chip, which supports a 240x135 pixel resolution and 16-bit color depth (65K colors). This display operates at 3.3V logic, making it directly compatible with the ESP32 without level shifters, but you must ensure the backlight pin (LED) is connected to a PWM-capable GPIO for brightness control. The SPI clock frequency can go up to 80 MHz on the ESP32, but for stable operation, 40 MHz is recommended to avoid signal degradation over longer wires.

Hardware wiring specifics: The display typically has 8 pins: VCC (3.3V), GND, CS (Chip Select), RESET, DC (Data/Command), MOSI (Master Out Slave In), SCK (Serial Clock), and LED (Backlight). For the ESP32, assign CS to GPIO 5, RESET to GPIO 4, DC to GPIO 2, MOSI to GPIO 23, SCK to GPIO 18, and LED to GPIO 22 (or any PWM pin). Use 10kΩ pull-up resistors on CS and RESET lines if your display module lacks them, though most breakout boards include these. The backlight pin draws about 20 mA at full brightness, so a 100Ω resistor in series is optional but safe for limiting current. Connect VCC to the 3.3V output of the ESP32, which can supply up to 600 mA, enough for the display (around 40 mA total) and the ESP32 itself (80 mA in active mode).

SPI bus configuration: The ESP32 has three SPI controllers (VSPI, HSPI, and FSPI). For this display, use VSPI (default) with pins: MOSI=23, MISO=19 (not used), SCK=18, CS=5. The TFT_eSPI library allows custom pin mapping in the User_Setup.h file. Set #define TFT_CS 5, #define TFT_DC 2, #define TFT_RST 4, #define TFT_MOSI 23, #define TFT_SCLK 18, and #define TFT_BL 22. The library automatically handles the 240x135 resolution and ST7789 driver. For the Adafruit ST7789 library, you’ll need to initialize the display with Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST); and then call tft.init(240, 135);.

Power considerations: The ESP32’s 3.3V regulator on development boards like the ESP32 DevKit V1 can deliver up to 600 mA, but the ESP32 itself draws 80 mA, plus the display at 40 mA, leaving headroom for sensors. If you power the ESP32 via USB (5V), the onboard regulator handles the 3.3V rail. For battery operation, use a 3.7V LiPo battery with a boost converter to 3.3V, ensuring at least 200 mA capacity. The display’s backlight consumes 20 mA at full brightness, but you can reduce it to 5 mA via PWM (e.g., analogWrite(TFT_BL, 50)).

Software setup and initialization: Install the TFT_eSPI library via Arduino IDE (Library Manager). After installation, navigate to the libraries/TFT_eSPI/User_Setup.h file and uncomment #define ST7789_DRIVER. Set the display width and height: #define TFT_WIDTH 240 and #define TFT_HEIGHT 135. For rotation, the library supports setRotation(1) for landscape orientation. The initialization sequence in the library sends commands like SLPOUT (sleep out) and DISPON (display on), which take about 120 ms total. After that, you can fill the screen with tft.fillScreen(ST77XX_BLACK) and draw pixels using tft.drawPixel(x, y, color).

Performance benchmarks: At 40 MHz SPI clock, the TFT_eSPI library can fill the entire 240x135 screen in about 8 ms (using pushImage with a 16-bit buffer). The frame rate for simple animations (e.g., bouncing ball) reaches 60 fps with optimized code, but drops to 20 fps when using floating-point math. The ESP32’s dual-core 240 MHz processor handles DMA transfers via the SPI bus, reducing CPU overhead by 30% compared to blocking writes. For graphics, the library uses a 16-bit color format (RGB565), where each pixel takes 2 bytes, so a full screen buffer requires 240×135×2 = 64,800 bytes (63.3 KB). The ESP32’s SRAM (520 KB) can hold this buffer, but if you’re running Wi-Fi or Bluetooth, leave at least 100 KB free for stack and heap.

Common pitfalls and fixes: If the display shows white or garbled output, check the RESET pin connection—it must be pulled high or driven high by the ESP32 after power-up. Some displays require a hardware reset by toggling the RESET pin low for 10 ms. Another issue is incorrect SPI mode; the ST7789 expects mode 0 (CPOL=0, CPHA=0) or mode 3 (CPOL=1, CPHA=1), but the TFT_eSPI library defaults to mode 0. If you see flickering, add a 10 µF capacitor between VCC and GND near the display module to filter power noise. The backlight pin on some modules is inverted (active low), so you may need to set #define TFT_BL 22 and use digitalWrite(TFT_BL, LOW) to turn it on.

Advanced features: The display supports partial update mode via the CASET and RASET commands, allowing you to refresh only a 100x50 pixel region in 2 ms, useful for battery-powered devices. The TFT_eSPI library includes a sprite class (TFT_eSprite) for off-screen rendering, which reduces tearing. For example, create a sprite with TFT_eSprite spr = TFT_eSprite(&tft);, then spr.createSprite(100, 50);, draw on it, and push it to the display with spr.pushSprite(10, 10);. This technique uses 100×50×2 = 10,000 bytes of SRAM per sprite.

Data table: Pin mapping for ESP32 to 1.14 inch IPS display

Display PinESP32 GPIOFunctionNotes
VCC3.3VPowerOutput from ESP32 regulator
GNDGNDGroundCommon ground
CSGPIO 5Chip SelectActive low, pull-up resistor
RESETGPIO 4ResetActive low, pull-up resistor
DCGPIO 2Data/CommandHigh=data, low=command
MOSIGPIO 23SPI DataMaster out slave in
SCKGPIO 18SPI ClockUp to 40 MHz
LEDGPIO 22BacklightPWM-capable, 20 mA max

Code example for basic initialization: In Arduino IDE, after setting up the TFT_eSPI library, use the following sketch. Include #include and TFT_eSPI tft = TFT_eSPI();. In setup(), call tft.init();, tft.setRotation(1);, and tft.fillScreen(TFT_BLACK);. Then draw a rectangle: tft.fillRect(10, 10, 100, 50, TFT_RED);. The loop() can cycle through colors every second using delay(1000). For text, use tft.setTextColor(TFT_WHITE); and tft.drawString("Hello", 20, 20, 2); where the last parameter is font size (2 = 16x32 pixels).

Memory usage breakdown: The TFT_eSPI library itself takes about 12 KB of flash (program memory) and 4 KB of RAM for buffers. The display buffer for a 240x135 image at 16-bit color requires 64.8 KB, but the library uses a 32-byte line buffer for non-DMA writes, reducing RAM usage to 32 bytes. However, if you use sprites, each 100x50 sprite adds 10 KB. The ESP32’s total RAM is 520 KB, with 320 KB available for user applications after the OS and networking stack. Running Wi-Fi simultaneously consumes 40 KB for the TCP/IP stack, so plan accordingly.

Real-world application example: For a weather station, connect the display to ESP32 via the above wiring. Use the WiFiClientSecure library to fetch JSON data from OpenWeatherMap, parse it with ArduinoJson, and display temperature, humidity, and pressure. The screen can show a 48x48 pixel icon using a bitmap array stored in flash (e.g., const uint16_t icon[] PROGMEM = {0xFFFF, ...};). The refresh rate for text updates is 10 Hz, while the icon redraws at 30 Hz. The backlight can be dimmed to 10% brightness during night hours using an RTC module like DS3231.

Electrical characteristics: The ST7789V driver operates from 1.65V to 3.3V, but the display module typically includes a voltage regulator for the backlight. The logic input thresholds are 0.8V for low and 2.0V for high, well within the ESP32’s 3.3V output. The max SPI clock frequency is 80 MHz, but at 40 MHz, the signal rise time is 5 ns, which is acceptable for traces under 10 cm. The display consumes 25 mA in active mode with backlight off, and 45 mA with backlight at full brightness. In sleep mode (SLPIN command), it drops to 0.1 mA, but the ESP32 must toggle the backlight pin low to save power.

Troubleshooting specific errors: If the display shows a black screen after initialization, verify that the ST7789_DRIVER is defined in User_Setup.h. If the colors are inverted (e.g., red appears blue), check the #define TFT_INVERSION_ON setting—some modules require inversion. For garbled characters, ensure the SPI bus is not shared with other devices; if it is, use separate CS pins. The display’s reset timing requires a 10 ms low pulse after power-up, which the library handles automatically, but if you’re using a custom init, add pinMode(TFT_RST, OUTPUT); digitalWrite(TFT_RST, LOW); delay(10); digitalWrite(TFT_RST, HIGH); delay(120);.

Performance comparison with other displays: The 1.14 inch IPS screen has a 240x135 resolution, which is 32,400 pixels, compared to a 1.3 inch OLED (128x64, 8,192 pixels) or a 2.8 inch TFT (320x240, 76,800 pixels). The IPS panel offers 160° viewing angles and 400 cd/m² brightness, while OLEDs have higher contrast but lower lifespan (20,000 hours vs. 50,000 hours for IPS). The ST7789 driver supports 16-bit color, whereas some cheaper displays use 8-bit (262K colors) but with dithering. The SPI interface on the ESP32 achieves 40 MHz, which is faster than I2C (400 kHz) but slower than parallel 8-bit (80 MHz).

Optimization tips: Use the ESP32’s dual-core by running the display update on core 1 and Wi-Fi on core 0. In the TFT_eSPI library, enable DMA with #define SPI_DMA in User_Setup.h, which offloads SPI transfers to the DMA controller, reducing CPU usage from 40% to 5% during screen updates. For animations, precompute frames in RAM or flash and use pushImage with a pointer to the data. The library’s setAddrWindow function allows partial updates, which is critical for battery life—refreshing only a 50x50 pixel area takes 0.5 ms instead of 8 ms for full screen.

Power management for battery projects: To extend battery life, put the ESP32 into deep sleep and wake it every 10 seconds to update the display. Use a MOSFET to cut power to the display during sleep, as the display’s sleep mode still draws 0.1 mA. The TFT_eSPI library supports tft.writecommand(ST77XX_SLPIN); to put the display to sleep, but the backlight must be turned off via digitalWrite(TFT_BL, LOW);. For a 2000 mAh battery, the system can run for 20 hours with continuous updates, or 100 hours with 10-second intervals.

Data table: SPI clock frequency vs. fill time for 240x135 screen

SPI Clock (MHz)Full Screen Fill Time (ms)CPU Usage (%)Notes
103225Stable with long wires
201630Typical for breadboard
40840Recommended for performance
80460May require shielded wires

Library-specific details: The TFT_eSPI library (version 2.5.43) supports the ST7789 driver with automatic detection of the display’s MADCTL register for rotation. The default rotation (0) is portrait, but setRotation(1) gives landscape. The library’s pushColor function sends a single 16-bit color value, while pushColors sends an array. For smooth scrolling, use tft.setScrollMargins(0, 0); and tft.scrollTo(10);. The library also includes a font rendering engine for TrueType-like fonts, but for Chinese characters, you need to load a custom font file from SPIFFS or SD card.

Hardware variant considerations: Some 1.14 inch IPS modules have a 6-pin interface (without CS and RESET, using a fixed CS and shared RESET with the ESP32’s EN pin). In that case, connect CS to GND (always selected) and RESET to the ESP32’s EN pin via a 10kΩ resistor, but this is not recommended for multi-device SPI buses. The display’s breakout board may include a microSD card slot, which uses additional SPI pins (GPIO 13 for CS, GPIO 12 for MISO). If you use the SD card, ensure the SPI bus is not shared with the display without a demultiplexer, as both devices will conflict.

Real-world latency data: In a test with an ESP32 at 240 MHz, the time to send a single pixel via SPI at 40 MHz is 0.5 µs (16 clock cycles for 16 bits