[Resolved Case] Detecting a Defective st7789 Display Purchased on AliExpress! Verification Report on Defective vs. Working Units

This time, I purchased two types of displays for just under 500 yen each on AliExpress.

  • One has no CS pin and a resolution of 240×240 (Defective unit)

  • The other has no backlight pin and a resolution of 240×320 (Working unit)

I attempted to display images using a Raspberry Pi Pico (compatible board) and the st7789_mpy library. For the firmware, I used the one provided for the Raspberry Pi Pico by st7789_mpy.
I went through a long process of trial and error with the defective display. However, I eventually noticed that the screen was flickering slightly. I also realized that what I thought was a smudge was actually dot artifacts caused by a malfunction. Since the working display showed images without any issues, I was able to conclude that the root cause was a hardware failure in the display itself.

目次

Troubleshooting Process

  1. Initial Setup and Wiring Check

    Using a Raspberry Pi Pico compatible board and the st7789_mpy library, I thoroughly reviewed the settings for each SPI pin (SCK, SDA, RES, DC). Since the defective display lacks a CS pin, I commented out the CS configuration line for testing.

  2. Extended Trial and Error

    Because the defective display showed no signs of life at all, I repeatedly checked the code and connections. However, at one point, I noticed the screen was flickering slightly, which tipped me off to the possibility of a hardware defect. Upon closer inspection, I saw that what looked like dirt was actually defective pixels, leading me to conclude that the display unit itself was faulty.
    *Dot noise can be seen inside the green box (not dirt)
    st7789 defective display

  3. Verification with the Working Display

    The working display features a CS pin instead of a backlight pin. I swapped the backlight and CS pin configurations, updated the display size from 240×240 to 240×320, and used the exact same settings and code otherwise. Testing with the working display yielded normal operation. This confirmed that there were no issues with the software configuration or wiring, and that the original display was indeed broken.

Firmware Flashing and Development Environment

  • Firmware Flashing
    To use st7789_mpy, I flashed the provided firmware.uf2 onto the Raspberry Pi Pico using Thonny.

  • Development Environment
    I used Thonny to write and upload the MicroPython code and verify the display operation.

Final Code Example

Based on the st7789_mpy sample code, I verified operation using the following code.

tft_config.py

from machine import Pin, SPI
import st7789

TFA = 40  # top free area when scrolling
BFA = 40  # bottom free area when scrolling

def config(rotation=0, buffer_size=0, options=0):
    return st7789.ST7789(
        SPI(0, baudrate=62500000, sck=Pin(18), mosi=Pin(19)),
        240,
        320,
        reset=Pin(21, Pin.OUT),
        cs=Pin(17, Pin.OUT),
        dc=Pin(16, Pin.OUT),
        # backlight=Pin(20, Pin.OUT),
        rotation=rotation,
        options=options,
        buffer_size=buffer_size)

main.py

import random
import utime
import st7789
import tft_config
import vga2_bold_16x32 as font

print('config')
tft = tft_config.config(0, 0, 0)

def center(text):
    length = 1 if isinstance(text, int) else len(text)
    tft.text(
        font,
        text,
        tft.width() // 2 - length // 2 * font.WIDTH,
        tft.height() // 2 - font.HEIGHT // 2,
        st7789.WHITE,
        st7789.RED)

def main():
    tft.init()
    tft.fill(st7789.WHITE)
    utime.sleep(2)
    tft.fill(st7789.RED)
    utime.sleep(2)
    center(b'\xAEHello\xAF')
    utime.sleep(2)
    tft.fill(st7789.BLACK)

    while True:
        for rotation in range(4):
            tft.rotation(rotation)
            tft.fill(0)
            col_max = tft.width() - font.WIDTH*6
            row_max = tft.height() - font.HEIGHT

            for _ in range(128):
                tft.text(
                    font,
                    b'Hello!',
                    random.randint(0, col_max),
                    random.randint(0, row_max),
                    st7789.color565(
                        random.getrandbits(8),
                        random.getrandbits(8),
                        random.getrandbits(8)),
                    st7789.color565(
                        random.getrandbits(8),
                        random.getrandbits(8),
                        random.getrandbits(8)))

This code is based on the st7789_mpy sample code and achieves display initialization, screen clearing, and center text rendering.

  • Displaying st7789 on a Raspberry Pi Pico clone

st7789 display

  • Displaying st7789 on an RP2040-Zero clone
    st7789 display on RP2040-Zero clone

Conclusion

Through this verification, it became clear that the issue with the defective display was a hardware defect in the unit itself. While displays can be purchased very cheaply on AliExpress, quality can vary between individual units. If you encounter similar issues in your own projects, it is a good idea to suspect hardware failure.
Having confirmed that everything works properly with a working display, I can now proceed with my projects with peace of mind.
I hope this serves as a helpful reference for your developments. If you have any questions or feedback, please feel free to leave a comment.