Web Analytics Made Easy -
StatCounter
Add an ST7735 TFT display to an ESP32 – Devacron.com

Add an ST7735 TFT display to an ESP32

Hello,

I wanted to try these ST7735 inexpensive displays that can be found all over the internet, so I ordered a couple for a few euros each. My quick research showed that a number of libraries support them and it turns out that you can display anything you want. Of course, we are not talking about playing modern games on it or watching 4k videos. These are just simple displays that can be really helpful to any project.

I used an older version of ESP32, the DEVKITV1, and actually the smaller version with the 30 pins. If you have a different one please try to find the correct pinout because they differ. Here is the pinout diagram from mine

And here is how the TFT looks. As you see it also has a port for an SD card if you want to use e.g. for reading images from it. In my case, I didn’t connect it.

1PCS 1.8 inch 1.8" TFT LCD Display module ST7735S 128x160 51/AVR/STM32/ARM 8/16 bit
1PCS 1.8 inch 1.8" TFT LCD Display module ST7735S 128x160 51/AVR/STM32/ARM 8/16 bit

The resolution is 128×160 pixels and this is something you need to be aware of since you may need to configure it in your code.

The connections are:

TFTESP32
5VVIN
GNDGND
LEDVIN
SCL (SPI Clock)GPIO18 VSPI SCK (SPI Clock)
SDA (SPI Data)GPIO23 VSPI MOSI (MOSI, Data to Screen)
RS (Register Select)GPIO2 (labelled as DC in Adafruit code)
RST (Screen reset)GPIO4
CS (Chip Select) GPIO5 VSPI SS (Slave Select/ Chip Select)

Once you have the connections ready next step is to install the TFT library in your Arduino IDE. Go to Tools – > Manage Libraries and then search for TFT_eSPI and click install. Alternatively, crab the lib from here.

Next step is to configure the pins in the file User_Setup.h of the library. In your favourite text editor open the file and change the pins in lines 124,125,126. Here how mine looks:

After this, you can pick any of the examples from the library to upload to your ESP32 microcontroller. Some of them are really nice. For testing, I connected a DHT11 temperature/humidity sensor and I displayed the readings in the ST7735. Sweet!

And here is my code if you want to copy it.

The code is not 100% as I need to find a better way to update the screen instead of filling the whole screen with black background before an update. There is documentation about it here https://learn.adafruit.com/adafruit-gfx-graphics-library/graphics-primitives I need to go through it.

Also as you can see I am using a custom font for the text so you will need to include the Final_Frontier_28.h file. It will probably be easier to change the code from the example Print_Smooth_Font. This is what I did any.

Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.