How to Use a 1.14 Inch IPS Display with MicroPython
To get a 1.14 inch 240x135 ips display working with MicroPython, you need to wire it up to a microcontroller like the Raspberry Pi Pico or ESP32, then use the st7789 or st7735 driver library. These displays usually use the ST7789V controller, which handles 240x135 pixel resolution with 16-bit color depth. Start by connecting the SPI pins: SCK (clock), MOSI (data), CS (chip select), DC (data/command), and RST (reset). Power the display with 3.3V and ground. For a Raspberry Pi Pico, typical pin mapping is: SCK to GP2, MOSI to GP3, CS to GP4, DC to GP5, RST to GP6, with backlight on GP7. The SPI bus runs at 20 MHz to 40 MHz, but you can push it to 62.5 MHz for faster refresh. The display draws about 20 mA at 3.3V, so it's fine for battery projects.
Once wired, flash MicroPython firmware to your board. For the Pico, download the UF2 file from the official site, hold the BOOTSEL button, plug it in, and drag the file to the RPI-RP2 drive. For ESP32, use esptool.py to erase and flash the bin file. Then, install the st7789py library from GitHub or use the built-in framebuf module. The driver needs initialization parameters: width=240, height=135, and rotation. The display's SPI interface uses 4-wire mode, so you must set the DC pin high for data and low for commands. The initialization sequence includes commands like SWRESET (0x01), SLPOUT (0x11), COLMOD (0x3A) to set 16-bit color, and DISPON (0x29). The display's refresh rate is about 60 Hz, but with MicroPython, you'll get around 10-15 frames per second for bitmap fills due to interpreter overhead.
For practical coding, here's a minimal example. Import the library, create an SPI object, then instantiate the display. Use display.fill() to clear the screen, display.pixel() for single dots, and display.text() for fonts. The framebuf module supports 8x8 and 8x16 fonts, but you can load custom fonts via bitmap arrays. The display's color format is RGB565, so pack colors as 16-bit integers: red (5 bits), green (6 bits), blue (5 bits). For example, 0x001F is blue, 0x07E0 is green, 0xF800 is red. You can precompute color tables for gradients. The display's viewing angle is 160 degrees, and its contrast ratio is 500:1, typical for IPS panels. The response time is 25 ms, so it's fine for static images but not for fast video.
To display images, convert them to 240x135 RGB565 raw data. Use Python's PIL library on your PC to resize and convert, then save as a binary file. Load it onto the board's flash memory (the Pico has 2 MB, but you can use an SD card for more). The display's SPI buffer is 64 bytes, so you need to send data in chunks. For full-screen images, send 240*135*2 = 64,800 bytes. At 40 MHz SPI, that takes about 1.6 ms, but MicroPython overhead adds 50-100 ms. Use machine.SPI.write() with a bytearray for speed. For animations, precompute frames and use double buffering with a framebuf object. The Pico's RAM is 264 KB, enough for two 64 KB frame buffers. The ESP32 has 520 KB SRAM, so you can handle more frames.
Power consumption is critical for portable devices. The display's backlight uses a white LED with 3.2V forward voltage and 20 mA current. You can control brightness via PWM on the backlight pin. Set the PWM frequency to 1 kHz to avoid flicker. At 50% duty cycle, current drops to 10 mA. The display's sleep mode (SLPIN command) reduces current to 0.5 mA. Use display.sleep_mode(True) to save power. The ST7789V controller has a built-in voltage regulator that handles 2.8V to 3.3V, so don't exceed 3.6V. The display's operating temperature range is -20°C to 70°C, suitable for most indoor and outdoor use.
For touch input, this display doesn't include a touch panel, but you can add a resistive touch overlay or use capacitive touch buttons on the microcontroller. The display's glass thickness is 1.1 mm, and the module weighs 5 grams. The PCB has mounting holes for 2 mm screws, making it easy to integrate into enclosures. The SPI interface is compatible with 3.3V logic, but 5V tolerant pins on the MCU need level shifters. The display's CS pin can be tied to ground if it's the only SPI device, but using a dedicated pin allows multiple peripherals. The maximum SPI clock speed is 62.5 MHz, but some modules may have issues above 40 MHz due to signal integrity. Keep wires under 10 cm for reliable operation.
When debugging, check the initialization sequence. Common issues include wrong pin mapping, missing pull-up resistors on CS and DC, or incorrect SPI mode (mode 0 or 3). The display expects SPI mode 0 (CPOL=0, CPHA=0) or mode 3 (CPOL=1, CPHA=1). Most libraries use mode 0. Use an oscilloscope to verify clock and data signals. The display's reset pin needs a low pulse of at least 10 µs. If the screen stays blank, try a hardware reset by toggling the RST pin low for 100 ms. The backlight pin should be high for on. Some modules have a built-in resistor for the backlight, so you can connect it directly to 3.3V for full brightness.
For advanced usage, you can implement partial updates. The ST7789V supports windowed addressing with commands CASET (0x2A) and RASET (0x2B). Set the column and row start/end coordinates, then send pixel data. This reduces SPI traffic for small updates. For example, to update a 50x50 icon, send only 5,000 bytes instead of 64,800. The display's memory write time is 120 ns per pixel, so partial updates are fast. You can also use the display's vertical scrolling feature with command VSCSAD (0x37). This is useful for scrolling text or menus. The display has a 240x240 pixel internal RAM, but only 240x135 is visible. The extra rows can be used for off-screen buffers.
Software libraries like micropython-st7789 by russhughes provide optimized routines for drawing shapes, text, and images. They use viper code for speed. The library includes functions for drawing lines, circles, rectangles, and polygons. For text, it supports multiple fonts via bitmap data. The default font is 8x8 pixels, but you can load 16x32 fonts for larger text. The library also handles rotation (0, 90, 180, 270 degrees). The display's orientation is landscape by default, but you can rotate to portrait for different layouts. The library's display.rotation attribute changes the coordinate system.
For data visualization, you can plot graphs using the framebuf line drawing. The display's 135 pixels height is enough for simple charts. Use display.hline() for horizontal lines and display.vline() for vertical. For bar charts, fill rectangles with display.fill_rect(). The display's color depth allows 65,536 colors, so you can use color gradients for heatmaps. The SPI bus speed limits real-time updates, but for static charts, it's fine. The display's gamma correction is set by default, but you can adjust it with command GMCTRP1 (0xE0) and GMCTRN1 (0xE1). The default gamma curve is 2.2, suitable for most applications.
When using the display with ESP32, note that the default SPI pins are different. Use VSPI (HSPI) with SCK=18, MOSI=23, MISO=19 (not used), CS=5, DC=4, RST=2. The ESP32's SPI can run at 80 MHz, but the display's limit is 62.5 MHz. The ESP32 has more RAM and flash, so you can store multiple images. The MicroPython firmware for ESP32 includes the neopixel and onewire libraries, but you need to install the st7789 driver manually. Use upip to install packages from the MicroPython repository. For example, run import upip; upip.install('micropython-st7789').
The display's mechanical dimensions are 30.5 mm x 18.5 mm x 3.5 mm (including PCB). The active area is 24.5 mm x 13.8 mm, giving a pixel density of 245 PPI. This is sharp for text and icons. The display's surface is glossy, so it may reflect light in bright environments. For outdoor use, consider a matte screen protector. The display's viewing angle is 160 degrees horizontally and vertically, so it's readable from almost any angle. The contrast ratio is 500:1, typical for IPS panels. The color gamut is 60% NTSC, which is adequate for most applications but not for professional color work.
For real-world projects, this display works well for weather stations, digital clocks, game consoles, and sensor readouts. The 240x135 resolution is a good balance between detail and SPI bandwidth. For a clock, update the time every second using partial updates. For a game, use double buffering to avoid tearing. The display's refresh rate is 60 Hz, but MicroPython's frame rate is limited by the interpreter. For faster performance, use the machine.SPI.write() method directly with precomputed buffers. The Pico's PIO (Programmable I/O) can drive the SPI at higher speeds, but that requires C code. The display's SPI interface is compatible with 3.3V logic, so you can use it with any microcontroller that has SPI.
When ordering, check the module's pinout. Some modules have a different order for SPI pins. The standard pinout is: 1-VCC, 2-GND, 3-SCK, 4-MOSI, 5-CS, 6-DC, 7-RST, 8-BL. Some modules have a 9th pin for MISO, but it's not used. The module's operating voltage is 3.3V, but some have a built-in regulator that accepts 5V. Check the datasheet for your specific module. The display's driver IC is ST7789V, which is widely supported. The initialization sequence is standard, but some modules may need slight adjustments. The display's memory is 240x240 pixels, but only 240x135 are visible. The extra rows can be used for scrolling or off-screen buffers.
For troubleshooting, common issues include: no display (check power, SPI pins, and initialization), garbled image (check SPI mode and clock speed), wrong colors (check color format, 16-bit vs 18-bit), and flickering (check backlight PWM frequency). Use a logic analyzer to debug SPI transactions. The display's command set includes 0x36 (MADCTL) for orientation, 0x3A (COLMOD) for color mode, and 0x21 (INVON) for inversion. The display's sleep mode is entered with 0x10 (SLPIN) and exited with 0x11 (SLPOUT). The display's idle mode (0x39) reduces power but disables partial updates. The display's normal mode (0x13) is for full operation.
For advanced graphics, you can use the micropython-ili9341 library, which is compatible with ST7789 after minor changes. The library supports sprites, tilemaps, and bitmap fonts. For animations, use the uasyncio library to manage timing. The display's SPI bus is not shared with other devices, so you can use it exclusively. The display's CS pin can be tied to ground to save a GPIO pin, but then you can't use other SPI devices. The display's DC pin is essential for command/data differentiation. The display's RST pin can be connected to the MCU's reset pin for automatic reset, but a dedicated pin is better for manual control.
The display's power-on sequence is: wait 10 ms after power-up, then send SWRESET, wait 120 ms, send SLPOUT, wait 120 ms, send COLMOD, wait 10 ms, send DISPON, wait 10 ms. The display's power-off sequence is: send SLPIN, wait 120 ms, then turn off power. The display's backlight can be controlled independently. For battery-powered projects, use a MOSFET to switch the backlight off completely. The display's current consumption without backlight is 1 mA. The display's sleep mode current is 0.5 mA. The display's deep sleep mode (with hardware reset) consumes 0.1 mA, but you lose the display state.
For data logging, you can display sensor readings in real time. Use the display's text function to show numbers. The default font is 8x8 pixels, so you can fit 30 characters per line and 16 lines. For larger fonts, use 16x32 pixels, which gives 15 characters per line and 4 lines. The display's color allows you to highlight important values. The display's SPI bus can be shared with an SD card module, but you need to use different CS pins. The SD card's SPI speed is typically 20 MHz, so it's compatible. The display's buffer is 64 bytes, so you can send data in chunks. The MicroPython framebuf module supports 8, 16, and 32-bit color depths, but 16-bit is best for this display.
For game development, the display's resolution is suitable for simple games like Tetris, Snake, or Pong. The 135 pixels height is enough for a 10x10 grid. The display's response time is 25 ms, so there's no ghosting. The SPI bus speed limits the frame rate, but for turn-based games, it's fine. For action games, use precomputed sprites and double buffering. The Pico's 264 KB RAM can hold two 64 KB buffers plus game logic. The ESP32's 520 KB RAM can hold more sprites. The display's color depth allows 65,536 colors, so you can use 8-bit sprites with a palette for memory efficiency.
For IoT applications, the display can show Wi-Fi status, IP address, and sensor data. Use the network module to connect to Wi-Fi, then update the display periodically. The display's SPI bus is not affected by Wi-Fi interference. The display's current consumption is 20 mA, so it's fine for battery-powered devices with a 1000 mAh battery. The display's backlight can be dimmed to extend battery life. The display's sleep mode is useful for deep sleep applications. The ESP32's deep sleep current is 10 µA, so the display's 0.5 mA sleep current is the main power draw. Use a MOSFET to cut power to the display completely during deep sleep.
For manufacturing, the display's module is RoHS compliant and lead-free. The display's PCB is 1.6 mm thick with ENIG finish. The display's connector is a 8-pin 0.5 mm pitch FPC, so you need a matching connector on your board. The display's operating temperature range is -20°C to 70°C, so it's suitable for most environments. The display's storage temperature range is -30°C to 80°C. The display's humidity range is 10% to 90% non-condensing. The display's ESD rating is 2 kV (HBM), so use proper handling procedures. The display's lifetime is 20,000 hours for the backlight LED. The display's warranty is typically 12 months.
For community support, check the MicroPython forum and GitHub repositories. The st7789py library has over 500 stars and is actively maintained. The library's documentation includes examples for drawing shapes, text, and images. The library's API is similar to the Adafruit GFX library, so it's easy to port code. The library's performance is optimized for MicroPython, with viper code for critical functions. The library's license is MIT, so you can use it in commercial projects. The library's dependencies include framebuf, which is built into MicroPython. The library's installation is simple: copy the st7789py.py file to your board's flash.
For testing, use a simple script to fill the screen with colors. Write a loop that sets each pixel to a different color. The display's response time is 25 ms, so you can see the update. Use display.fill(0x001F) for blue, display.fill(0x07E0) for green, and display.fill(0xF800) for red. Then draw a white rectangle in the center. The display's contrast ratio is 500:1, so white is bright and black is dark. The display's viewing angle is 160 degrees, so you can see the colors from the side. The display's color gamut is 60