# Help installing a display(ST7735) to my Raspberry Pi

#### Leo17

Joined Nov 18, 2020
16
Hello guys!
As the subject says, i can't install this display which is a ST7735 i believe on my Raspberry Pi Zero W. I found a lot of tutorials about wiring it and installing it but no one looks the same as mine do since mine has more pins and i really don't know which pin goes where.

Those are the pics of the display. If anyone can help me with telling which pin goes where on my raspberry and how can i install it i would be grateful.I need this for a project.
Thank you a lot for your time!

#### DizzyToo

Joined Dec 8, 2017
3
I'm no expert, but here is my take on this ...

From the PIN names it looks like an SPI interface, and from the chips on the board it looks like it's a 5v board, but it might still expect 3.3v on the data lines. You will need to confirm that before you start plugging in anything. You have a few things to find out from the supplier/datasheet. What voltage does does VCC expect. What voltage does the LED expect, and what voltage do the data lines expect. They don't all need to be the same voltage, but they do need to be correct for the device they are connected to. I would expect the Raspberry Pi to make 3.3v & 5v available, but the data lines will probably all be a fixed voltage, and my guess would be 3.3v.

I know nothing about the Raspberry Pi, but if it's like the microcontrollers I use, then you can use software or hardware SPI. That means the pins you could use on the microcontroller aren't fixed, but they do need to match the pins defined in the software (in the ST7735 driver software or more likely, in your first call to the driver).

Note that you can hard wire the LED on, or have it under microcontroller control so it can be dimmed, but you will need it on to see anything on the display. Either way, I suggest you start with it hard wired on. It uses one less pin on the controller, and is one less thing to debug.

These small TFT modules don't seem to adhere to any sort of standard for naming the pins. This is my best guess for the board you have.

CLK <--> SPI clock(SCK)
SDI <--> Serial data input (MOSI)
RS <--> Data/Command (D/C)
CS <--> chip/slave select (SS)
LED <--> Display backlight on/off. Some are active low
RST <--> (Reset) - see the datasheet, but this can probably be left disconnected

Note that this is a slave SPI device, and it doesn't "talk" to the master (the microcontroller), so it doesn't have a MISO connection.

Good luck ...

#### geekoftheweek

Joined Oct 6, 2013
623
I didn't read it all, but it started good and has some drawings and such to explain things a bit more... http://w8bh.net/pi/TFT1.pdf

#### DizzyToo

Joined Dec 8, 2017
3
A couple of things to note about the page you reference. The board there can handle voltages between 3v & 5v on all it's pins. The program uses software SPI and the code 'bit bangs' the comms lines to communicate with the graphics board. Also ... it contains enough ST7735 driver code to get stuff done, so no external libraries are required. The code defines the data connections as follows:

Variable Pin
======== ===
SCLK = 24 (Connect this pin to the CLK pin on your board)
SDAT = 23 (Connect this pin to the SDI pin on your board)
DC = 25 (Connect this pin to the RS pin on your board)

From your photo's, I'm guessing that the following are true for your board:
U1 - voltage regulator to step down an externally supplied 5v (on VCC) down to 3.3v internally
J1 - when linked bypasses the voltage regulator to turn the board into a 3.3v board
Q1 - is a transistor that drives the LED backlight.

Note that the pins at each end of your board are essentially the same connections, just laid out & labelled differently

I have had a look to see if I can find details for you board on-line, but have been unable to do so, so you are going to have to help yourself here. You need to confirm that it has an ST7735 controller, and what voltages the pins on the graphics board need. This is basic information & should be available from the supplier of the board.

If you want to take a chance (RPis aren't cheap!), I would be tempted to bridge the connections at J1, and go with 3.3V for the whole graphics board. The LED may still require 5v, but it will survive for a while at 3.3v.

Just bear in mind the first 3 words of my original post!

#### Leo17

Joined Nov 18, 2020
16
A couple of things to note about the page you reference. The board there can handle voltages between 3v & 5v on all it's pins. The program uses software SPI and the code 'bit bangs' the comms lines to communicate with the graphics board. Also ... it contains enough ST7735 driver code to get stuff done, so no external libraries are required. The code defines the data connections as follows:

Variable Pin
======== ===
SCLK = 24 (Connect this pin to the CLK pin on your board)
SDAT = 23 (Connect this pin to the SDI pin on your board)
DC = 25 (Connect this pin to the RS pin on your board)

From your photo's, I'm guessing that the following are true for your board:
U1 - voltage regulator to step down an externally supplied 5v (on VCC) down to 3.3v internally
J1 - when linked bypasses the voltage regulator to turn the board into a 3.3v board
Q1 - is a transistor that drives the LED backlight.

Note that the pins at each end of your board are essentially the same connections, just laid out & labelled differently

I have had a look to see if I can find details for you board on-line, but have been unable to do so, so you are going to have to help yourself here. You need to confirm that it has an ST7735 controller, and what voltages the pins on the graphics board need. This is basic information & should be available from the supplier of the board.

If you want to take a chance (RPis aren't cheap!), I would be tempted to bridge the connections at J1, and go with 3.3V for the whole graphics board. The LED may still require 5v, but it will survive for a while at 3.3v.

Just bear in mind the first 3 words of my original post!
Hello and thank you for the info it was really welcomed! I wired it with my breadboard on my pi with the info you and geekoftheweek provided, and the screen turns all white. I tried installing the script from the pdf mentioned above but in line 63 if i remember corectly it was a code line " def SetPin(pinNumber,value): " where the program stops. It might be because i have to change the "PinNumber" to a pin from my board but i am not sure about it. Also, i did not wire the CS pin because i did not know where to put it. If you have any idea what to do about those things you're amazing. Well, you already are but even more! Thank you a lot guys.

#### DizzyToo

Joined Dec 8, 2017
3
Can you provide a link to the board you purchased?
Do you know what voltages it expects/needs?
Have you bridged the connections marked J1 on the board?

The white screen is just the LED backlight switched on, that's correct for a TFT when no data is showing on the screen.

If you have multiple slaves on your SPI bus, then you need to connect the CS pin to an o/p pin on the RPi, and select the graphics board when you want to write to it. I suspect you just have this graphics board on the SPI bus, so if that is the case, CS simply needs to be connected to either high (3.3v), or low (0v) to keep the board permanently selected. The datatsheet for the board will show which it is, but normally CS will be pulled low to select the device.

I'm not a python programmer, but the line you reference is a routine that is called from elsewhere in that code to set the output on the GPIO pin. I understand that Python does on the fly compilation at runtime, so I'm guessing that there is a syntax error in that routine during compilation; rather than an error in the values passed to it when executing.

#### geekoftheweek

Joined Oct 6, 2013
623
Glad to hear it is working for you somewhat. The CS pin on your display would be the same as the TFT select pin in the pdf and for that example it is tied to ground. Normally you would connect that to an output on whatever is driving the display to be able to select between multiple devices on the SPI pins. If CS is high it ignores the signals on the clock and data lines, and if CS is low then it reads / writes to the data lines. With just the display connected it's not really needed.

Does the program give any sort of error messages when it stops?

I don't know Python myself either, but I did some tracing through the code. The first call I could find to SetPin() happens in the InitDisplay() routine by way of calling WriteCmd() which then calls WriteByte() and then finally calls SetPin(). My initial thought was a permission problem (which it still could possibly be), but there are several other calls to GPIO setup functions before calling SetPin() that should have caused a problem already if it were a permission issue I would think.

I didn't catch on at first to the bit banging in the link I mentioned. I saw all the illustrations and thought that was some good background information and didn't pay attention to the code. It does give pretty much all the needed information though to write your own application if you choose.

#### geekoftheweek

Joined Oct 6, 2013
623
Going with the permission thought try doing sudo tft_display (or whatever your script is) and see if that makes a difference.

#### Leo17

Joined Nov 18, 2020
16
Hello again! I tied the CS pin to ground as mentioned and i ran again the python script the error is: File "Home/pi/mu_code/display1.py", line 62 GPI0.setup(pin,GPI0.OUT)
IndentationError : expected an indented block
Glad to hear it is working for you somewhat. The CS pin on your display would be the same as the TFT select pin in the pdf and for that example it is tied to ground. Normally you would connect that to an output on whatever is driving the display to be able to select between multiple devices on the SPI pins. If CS is high it ignores the signals on the clock and data lines, and if CS is low then it reads / writes to the data lines. With just the display connected it's not really needed.

Does the program give any sort of error messages when it stops?

I don't know Python myself either, but I did some tracing through the code. The first call I could find to SetPin() happens in the InitDisplay() routine by way of calling WriteCmd() which then calls WriteByte() and then finally calls SetPin(). My initial thought was a permission problem (which it still could possibly be), but there are several other calls to GPIO setup functions before calling SetPin() that should have caused a problem already if it were a permission issue I would think.

I didn't catch on at first to the bit banging in the link I mentioned. I saw all the illustrations and thought that was some good background information and didn't pay attention to the code. It does give pretty much all the needed information though to write your own application if you choose.

#### Leo17

Joined Nov 18, 2020
16
Can you provide a link to the board you purchased?
Do you know what voltages it expects/needs?
Have you bridged the connections marked J1 on the board?

The white screen is just the LED backlight switched on, that's correct for a TFT when no data is showing on the screen.

If you have multiple slaves on your SPI bus, then you need to connect the CS pin to an o/p pin on the RPi, and select the graphics board when you want to write to it. I suspect you just have this graphics board on the SPI bus, so if that is the case, CS simply needs to be connected to either high (3.3v), or low (0v) to keep the board permanently selected. The datatsheet for the board will show which it is, but normally CS will be pulled low to select the device.

I'm not a python programmer, but the line you reference is a routine that is called from elsewhere in that code to set the output on the GPIO pin. I understand that Python does on the fly compilation at runtime, so I'm guessing that there is a syntax error in that routine during compilation; rather than an error in the values passed to it when executing.
I did not bridge anything, and when i bought it said it s a ST7735, the thing is unfortunately there is no more info about it on their website

#### geekoftheweek

Joined Oct 6, 2013
623
File "Home/pi/mu_code/display1.py", line 62 GPI0.setup(pin,GPI0.OUT)
IndentationError : expected an indented block
The only place I could find GPI0.setup(pin,GPI0.OUT) in the pdf was:

Code:
def InitIO():
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
for pin in pins:
GPIO.setup(pin,GPIO.OUT)
GPIO.output(SCLK,0)
My guess is your indentation is wrong somewhere in the file either at line 62 or after. It is more or less how Python separates loops, conditionals, and whatever other sections.