TFT display SPI

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
lbayo
Posts: 24
Joined: Tue Mar 16, 2021 2:10 pm

TFT display SPI

Post by lbayo » Wed Apr 21, 2021 2:06 pm

Hi,

I have a board with a 128x64 OLED display with SPI interface and it works correctly. The SPI connection is correct.
When I replace that display with another TFT IPS 240x240 (using the st7789 libraries) it doesn't work at all.
I also observe that between the pins of the new TFT, the one of CS is missing and in its place a BLK pin appears (backlight?)
How must it be connected for it to work?

Test code is

Code: Select all

from machine import Pin, SoftSPI
from time import sleep
import st7789
tft = st7789.ST7789(
    SoftSPI( baudrate=300000, polarity=1, phase=1, sck=Pin(19), mosi=Pin(21), miso=Pin(0)),
    240,
    240,
    reset=Pin(5, Pin.OUT),
    dc=Pin(17, Pin.OUT),
    cs=Pin(15, Pin.OUT),
    backlight=Pin(4, Pin.OUT))

tft.init()
tft.fill(st7789.WHITE)                
sleep(1)
tft.fill(st7789.color565(255,0,0))    

User avatar
russ_h
Posts: 88
Joined: Thu Oct 03, 2019 2:26 am
Contact:

Re: TFT display SPI

Post by russ_h » Wed Apr 21, 2021 4:55 pm

I've seen several ST7789 display's with odd or different pin names. Can you post a picture showing the front and back of the display so we can see what the pins are named? Also a link to where you bought the display can be helpful.

lbayo
Posts: 24
Joined: Tue Mar 16, 2021 2:10 pm

Re: TFT display SPI

Post by lbayo » Wed Apr 21, 2021 7:38 pm

Your comment made me think that it could be a hardware problem. Indeed, one of the pins had a defective solder.
After reviewing the welds the display works.
Sometimes a trivial comment lets you see the light.
Thank you

lbayo
Posts: 24
Joined: Tue Mar 16, 2021 2:10 pm

Re: TFT display SPI

Post by lbayo » Wed Jun 09, 2021 4:37 pm

I can't get any of the 3 color TFT displays (IPS 240x240) to work for me despite the different tests carried out.
In the software, the MOSI, MISO, CLK, RESET, DC and CS pins are programmed but the display has (apart from Vcc and GND) SDA, SCL, RES, DC and BLK. I am clear that MOSI corresponds to SDA, CLK corresponds to SCL, RESET corresponds to RES and DC is straightforward. But I am not clear
a / Is the MISO pin programmed but not connected?
b / Also with pin CS. You have to program it but it doesn't exist?
c / What do I do with BLK? Do I schedule it? (yes / no), do I connect it? (where?)
Can someone clarify this ?
The system used is an ESP32 (WROOM-32) equipped with the firmware with the library with a TFT IPS 240x240 display.
IDE:Thonny

Prompt after reset

Code: Select all

MicroPython v1.14-150-g42035e5ed-dirty on 2021-04-11; ESP32 GENERIC-7789 with ESP32
Type "help()" for more information.
>>> 

Test program

Code: Select all

from machine import Pin, SoftSPI
from time import sleep
import st7789
tft = st7789.ST7789(
    SoftSPI( baudrate=300000, polarity=1, phase=1, sck=Pin(19,Pin.OUT), mosi=Pin(21,Pin.OUT), miso=Pin(0,Pin.IN)),
    240,
    240,
    reset=Pin(5, Pin.OUT),
    dc=Pin(17, Pin.OUT),
    cs=Pin(15, Pin.OUT),
    backlight=Pin(4, Pin.OUT))

tft.init()
tft.fill(st7789.WHITE)                
sleep(1)
tft.fill(st7789.color565(255,0,0))

User avatar
russ_h
Posts: 88
Joined: Thu Oct 03, 2019 2:26 am
Contact:

Re: TFT display SPI

Post by russ_h » Wed Jun 09, 2021 4:48 pm

I'm working on the next update of the driver as well as the documentation. This discussion should be helpful.

lbayo
Posts: 24
Joined: Tue Mar 16, 2021 2:10 pm

Re: TFT display SPI

Post by lbayo » Thu Jun 10, 2021 6:24 am

Thanks russ_h

lbayo
Posts: 24
Joined: Tue Mar 16, 2021 2:10 pm

Re: TFT display SPI

Post by lbayo » Thu Jun 10, 2021 6:28 am

If there is no CS pin in the display, I assume it is internally tied low ?

User avatar
russ_h
Posts: 88
Joined: Thu Oct 03, 2019 2:26 am
Contact:

Re: TFT display SPI

Post by russ_h » Thu Jun 10, 2021 7:38 pm

If there is no CS pin in the display, I assume it is internally tied low ?
Yes, they are usually tied low, so they are always selected.

Post Reply