{"id":5014,"date":"2026-08-30T02:50:36","date_gmt":"2026-08-29T17:50:36","guid":{"rendered":"https:\/\/donguri3.net\/server-tech\/aliexpress-st7789-display-troubleshooting-2\/"},"modified":"2026-08-30T02:50:37","modified_gmt":"2026-08-29T17:50:37","slug":"aliexpress-st7789-display-troubleshooting","status":"publish","type":"post","link":"https:\/\/donguri3.net\/en\/diy-repair\/electronics-microcontroller\/aliexpress-st7789-display-troubleshooting\/","title":{"rendered":"[Resolved Case] Detecting a Defective st7789 Display Purchased on AliExpress! Verification Report on Defective vs. Working Units"},"content":{"rendered":"<p class=\"\">This time, I purchased two types of displays for just under 500 yen each on AliExpress.<\/p>\n<ul>\n<li class=\"\">\n<p class=\"\">One has no CS pin and a resolution of 240\u00d7240 (Defective unit)<\/p>\n<\/li>\n<li class=\"\">\n<p class=\"\">The other has no backlight pin and a resolution of 240\u00d7320 (Working unit)<\/p>\n<\/li>\n<\/ul>\n<p class=\"\">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.<br \/>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.<\/p>\n<h2 class=\"\">Troubleshooting Process<\/h2>\n<ol>\n<li class=\"\">\n<p class=\"\"><strong>Initial Setup and Wiring Check<\/strong><\/p>\n<p>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.<\/li>\n<li class=\"\">\n<p class=\"\"><strong>Extended Trial and Error<\/strong><\/p>\n<p>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.<br \/>*Dot noise can be seen inside the green box (not dirt)<br \/>\n<a href=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16382.jpg\"><img decoding=\"async\" class=\"aligncenter wp-image-1044 size-large\" src=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16382-774x1024.jpg\" alt=\"st7789 defective display\" width=\"774\" height=\"1024\" srcset=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16382-774x1024.jpg 774w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16382-227x300.jpg 227w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16382-768x1016.jpg 768w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16382.jpg 1127w\" sizes=\"(max-width: 774px) 100vw, 774px\" \/><\/a><\/li>\n<li class=\"\">\n<p class=\"\"><strong>Verification with the Working Display<\/strong><\/p>\n<p>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&#215;240 to 240&#215;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.<\/li>\n<\/ol>\n<h2 class=\"\">Firmware Flashing and Development Environment<\/h2>\n<ul>\n<li class=\"\">\n<p class=\"\"><strong>Firmware Flashing<\/strong><br \/>To use st7789_mpy, I flashed the <a class=\"\" href=\"https:\/\/github.com\/russhughes\/st7789_mpy\/tree\/master\/firmware\/RP2\/firmware.uf2\" target=\"_new\" rel=\"noopener\">provided firmware.uf2<\/a> onto the Raspberry Pi Pico using Thonny.<\/p>\n<\/li>\n<li class=\"\">\n<p class=\"\"><strong>Development Environment<\/strong><br \/>I used Thonny to write and upload the MicroPython code and verify the display operation.<\/p>\n<\/li>\n<\/ul>\n<h2 class=\"\">Final Code Example<\/h2>\n<p>Based on the st7789_mpy sample code, I verified operation using the following code.<\/p>\n<h3 class=\"\">tft_config.py<\/h3>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\">\n<pre>from machine import Pin, SPI\nimport st7789\n\nTFA = 40  # top free area when scrolling\nBFA = 40  # bottom free area when scrolling\n\ndef config(rotation=0, buffer_size=0, options=0):\n    return st7789.ST7789(\n        SPI(0, baudrate=62500000, sck=Pin(18), mosi=Pin(19)),\n        240,\n        320,\n        reset=Pin(21, Pin.OUT),\n        cs=Pin(17, Pin.OUT),\n        dc=Pin(16, Pin.OUT),\n        # backlight=Pin(20, Pin.OUT),\n        rotation=rotation,\n        options=options,\n        buffer_size=buffer_size)<\/pre>\n<\/div>\n<\/div>\n<h3 class=\"\">main.py<\/h3>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\">\n<pre>import random\nimport utime\nimport st7789\nimport tft_config\nimport vga2_bold_16x32 as font\n\nprint('config')\ntft = tft_config.config(0, 0, 0)\n\ndef center(text):\n    length = 1 if isinstance(text, int) else len(text)\n    tft.text(\n        font,\n        text,\n        tft.width() \/\/ 2 - length \/\/ 2 * font.WIDTH,\n        tft.height() \/\/ 2 - font.HEIGHT \/\/ 2,\n        st7789.WHITE,\n        st7789.RED)\n\ndef main():\n    tft.init()\n    tft.fill(st7789.WHITE)\n    utime.sleep(2)\n    tft.fill(st7789.RED)\n    utime.sleep(2)\n    center(b'\\xAEHello\\xAF')\n    utime.sleep(2)\n    tft.fill(st7789.BLACK)\n\n    while True:\n        for rotation in range(4):\n            tft.rotation(rotation)\n            tft.fill(0)\n            col_max = tft.width() - font.WIDTH*6\n            row_max = tft.height() - font.HEIGHT\n\n            for _ in range(128):\n                tft.text(\n                    font,\n                    b'Hello!',\n                    random.randint(0, col_max),\n                    random.randint(0, row_max),\n                    st7789.color565(\n                        random.getrandbits(8),\n                        random.getrandbits(8),\n                        random.getrandbits(8)),\n                    st7789.color565(\n                        random.getrandbits(8),\n                        random.getrandbits(8),\n                        random.getrandbits(8)))\n<\/pre>\n<\/div>\n<\/div>\n<p>This code is based on the st7789_mpy sample code and achieves display initialization, screen clearing, and center text rendering.<\/p>\n<ul>\n<li>Displaying st7789 on a Raspberry Pi Pico clone<\/li>\n<\/ul>\n<p><a href=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16391-scaled.jpg\"><img decoding=\"async\" class=\"aligncenter wp-image-1042 size-large\" src=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16391-768x1024.jpg\" alt=\"st7789 display\" width=\"768\" height=\"1024\" srcset=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16391-768x1024.jpg 768w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16391-225x300.jpg 225w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16391-1152x1536.jpg 1152w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16391-1536x2048.jpg 1536w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_16391-scaled.jpg 1440w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/a><\/p>\n<ul>\n<li>Displaying st7789 on an RP2040-Zero clone<br \/>\n<a href=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_1641-scaled.jpg\"><img decoding=\"async\" class=\"aligncenter wp-image-1133 size-large\" src=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/04\/IMG_1641-819x1024.jpg\" alt=\"st7789 display on RP2040-Zero clone\" width=\"819\" height=\"1024\" \/><\/a><\/li>\n<\/ul>\n<h2 class=\"\">Conclusion<\/h2>\n<p class=\"\">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.<br \/>\nHaving confirmed that everything works properly with a working display, I can now proceed with my projects with peace of mind.<br \/>\nI hope this serves as a helpful reference for your developments. If you have any questions or feedback, please feel free to leave a comment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This time, I purchased two types of displays for just under 500 yen each on AliExpress. One has no CS pin and  [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":1317,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/donguri3.net\/?p=1031","footnotes":""},"categories":[1163],"tags":[434,265,47,277,262,272,104],"class_list":["post-5014","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-electronics-microcontroller","tag-aliexpress","tag-micropython","tag-python","tag-raspberry-pi-pico","tag-rp2040-zero","tag-thonny","tag-104","en-US"],"_links":{"self":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts\/5014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/comments?post=5014"}],"version-history":[{"count":1,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts\/5014\/revisions"}],"predecessor-version":[{"id":5017,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts\/5014\/revisions\/5017"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/media\/1317"}],"wp:attachment":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/media?parent=5014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/categories?post=5014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/tags?post=5014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}