esp32 arduino tft display factory

Just to clarify and add to David"s excellent advice above, here is how I successfully connecting ESP32 with some old "non Serial (without SPI)" TFT LCD.

My LCD by www.mcufriend.com requires both +3.3v and +5v BUT the ESP32 only has a 3.3v supply pin So to get the display working I needed to provide an external 5v supply.

esp32 arduino tft display factory

In this guide we’re going to show you how you can use the 1.8 TFT display with the Arduino. You’ll learn how to wire the display, write text, draw shapes and display images on the screen.

The 1.8 TFT is a colorful display with 128 x 160 color pixels. The display can load images from an SD card – it has an SD card slot at the back. The following figure shows the screen front and back view.

This module uses SPI communication – see the wiring below . To control the display we’ll use the TFT library, which is already included with Arduino IDE 1.0.5 and later.

The TFT display communicates with the Arduino via SPI communication, so you need to include the SPI library on your code. We also use the TFT library to write and draw on the display.

In which “Hello, World!” is the text you want to display and the (x, y) coordinate is the location where you want to start display text on the screen.

The 1.8 TFT display can load images from the SD card. To read from the SD card you use the SD library, already included in the Arduino IDE software. Follow the next steps to display an image on the display:

Note: some people find issues with this display when trying to read from the SD card. We don’t know why that happens. In fact, we tested a couple of times and it worked well, and then, when we were about to record to show you the final result, the display didn’t recognized the SD card anymore – we’re not sure if it’s a problem with the SD card holder that doesn’t establish a proper connection with the SD card. However, we are sure these instructions work, because we’ve tested them.

In this guide we’ve shown you how to use the 1.8 TFT display with the Arduino: display text, draw shapes and display images. You can easily add a nice visual interface to your projects using this display.

esp32 arduino tft display factory

We have used Liquid Crystal Displays in the DroneBot Workshop many times before, but the one we are working with today has a bit of a twist – it’s a circle!  Perfect for creating electronic gauges and special effects.

LCD, or Liquid Crystal Displays, are great choices for many applications. They aren’t that power-hungry, they are available in monochrome or full-color models, and they are available in all shapes and sizes.

Today we will see how to use this display with both an Arduino and an ESP32. We will also use a pair of them to make some rather spooky animated eyeballs!

There are also some additional connections to the display. One of them, DC, sets the display into either Data or Command mode. Another, BL, is a control for the display’s backlight.

The above illustration shows the connections to the display.  The Waveshare display can be used with either 3.3 or 5-volt logic, the power supply voltage should match the logic level (although you CAN use a 5-volt supply with 3.3-volt logic).

Another difference is simply with the labeling on the display. There are two pins, one labeled SDA and the other labeled SCL. At a glance, you would assume that this is an I2C device, but it isn’t, it’s SPI just like the Waveshare device.

This display can be used for the experiments we will be doing with the ESP32, as that is a 3.3-volt logic microcontroller. You would need to use a voltage level converter if you wanted to use one of these with an Arduino Uno.

The Arduino Uno is arguably the most common microcontroller on the planet, certainly for experiments it is. However, it is also quite old and compared to more modern devices its 16-MHz clock is pretty slow.

The Waveshare device comes with a cable for use with the display. Unfortunately, it only has female ends, which would be excellent for a Raspberry Pi (which is also supported) but not too handy for an Arduino Uno. I used short breadboard jumper wires to convert the ends into male ones suitable for the Arduino.

Once you have everything hooked up, you can start coding for the display. There are a few ways to do this, one of them is to grab the sample code thatWaveshare provides on their Wiki.

The Waveshare Wiki does provide some information about the display and a bit of sample code for a few common controllers. It’s a reasonable support page, unfortunately, it is the only support that Waveshare provides(I would have liked to see more examples and a tutorial, but I guess I’m spoiled by Adafruit and Sparkfun LOL).

Open the Arduino folder. Inside you’ll find quite a few folders, one for each display size that Waveshare supports. As I’m using the 1.28-inch model, I selected theLCD_1inch28folder.

Once you do that, you can open your Arduino IDE and then navigate to that folder. Inside the folder, there is a sketch file namedLCD_1inch28.inowhich you will want to open.

When you open the sketch, you’ll be greeted by an error message in your Arduino IDE. The error is that two of the files included in the sketch contain unrecognized characters. The IDE offers the suggestion of fixing these with the “Fix Encoder & Reload” function (in the Tools menu), but that won’t work.

You can see from the code that after loading some libraries we initialize the display, set its backlight level (you can use PWM on the BL pin to set the level), and paint a new image. We then proceed to draw lines and strings onto the display.

After uploading the code, you will see the display show a fake “clock”. It’s a static display, but it does illustrate how you can use this with the Waveshare code.

This library is an extension of the Adafruit GFX library, which itself is one of the most popular display libraries around. Because of this, there isextensive documentation for this libraryavailable from Adafruit.  This makes the library an excellent choice for those who want to write their own applications.

As with the Waveshare sample, this file just prints shapes and text to the display. It is quite an easy sketch to understand, especially with the Adafruit documentation.

The sketch finishes by printing some bizarre text on the display. The text is an excerpt from The Hitchhiker’s Guide to the Galaxy by Douglas Adams, and it’s a sample of Vogon poetry, which is considered to be the third-worst in the Galaxy!

Here is the hookup for the ESP32 and the GC9A01 display.  As with most ESP32 hookup diagrams, it is important to use the correct GPIO numbers instead of physical pins. The diagram shows the WROVER, so if you are using a different module you’ll need to consult its documentation to ensure that you hook it up properly.

The TFT_eSPI library is ideal for this, and several other, displays. You can install it through your Arduino IDE Library Manager, just search for “TFT_eSPI”.

There is a lot of demo code included with the library. Some of it is intended for other display sizes, but there are a few that you can use with your circular display.

To test out the display, you can use theColour_Test sketch, found inside the Test and Diagnostic menu item inside the library samples.  While this sketch was not made for this display, it is a good way to confirm that you have everything hooked up and configured properly.

A great demo code sample is theAnimated_dialsketch, which is found inside theSpritesmenu item.  This demonstration code will produce a “dial” indicator on the display, along with some simulated “data” (really just a random number generator).

In order to run this sketch, you’ll need to install another library. Install theTjpeg_DecoderLibrary from Library Manager. Once you do, the sketch will compile, and you can upload it to your ESP32.

One of my favorite sketches is the Animated Eyes sketch, which displays a pair of very convincing eyeballs that move. Although it will work on a single display, it is more effective if you use two.

The first thing we need to do is to hook up a second display. To do this, you connect every wire in parallel with the first display, except for the CS (chip select) line.

The Animated Eyes sketch can be found within the sample files for the TFT_eSPI library, under the “generic” folder.  Assuming that you have wired up the second GC9A01 display, you’ll want to use theAnimated_Eyes_2sketch.

The GC9A01 LCD module is a 1.28-inch round display that is useful for instrumentation and other similar projects. Today we will learn how to use this display with an Arduino Uno and an ESP32.

esp32 arduino tft display factory

A 80*160 pixel color display has the particular advantage that it is small: screen diagonal of 0.96 inch. This makes it attractive for use in (literally) small applications, particularly in scale models: railways, homes, cities. Attached to a ESP8266 and ESP32 microcontroller these displays can produce animations or day/night scenes, illuminated shop windows, traffic boards, advertisement panels and so forth. Here we wire a 0.96’ TFT with ST7735S controller to ESP8266 and ESP32 microcontroller boards

Model railway displays can be made more attractive by the addition of ‘live’ decoration: train station arrival/departure boards, information screens, advertisement boards, etcetera. Another type of decoration is animated shop windows. For this genre of application a miniature display can be an interesting option. All these applications have in common that any display used needs to be small, flat, economical and easy to fit, sometimes as retrofit, into the interior of plastic model structures such as model railway homes and Lego buildings. They even may be placed in structures belonging to model Christmas or Easter villages. The market supplies small monochrome displays, e.g. 0.91 inch diameter, 128*32 pixel OLED, the slightly bigger (0.96 inch), 64*128 pixel OLED, and the recently introduced 0.96’ 160*80 TFT. The OLEDS can be found in different versions (white, blue, yellow monochrome color). Very attractive is the 0.96’ TFT because it is capable of displaying 64k colors. Driven by a powerful ESP8266 or ESP32, animations can be run such as miniature billboards and advertisement boards. Static displays that change between day and night such as shop window illumination, are also among the possibilities. In this article we deal with the connectivity between a 0.96’, 160*80 pixel TFT and ESP8266 or ESP32 microcontroller boards. The TFT’s controller is a ST7735S which is perfectly supprted by Bodmer’s TFT_eSPI library.

Whilst the early ESP8266 development work was done with a configuration consisting of a breadboard with the display on it and with connections through jumper wires such assemblies perform very irregular. The 0.96′ SPI TFT responds very critically to imperfect wiring: one slightly loose jumper wire and the display won’t work. A minibench with soldered pin connectivity was therefore constructed for ESP8266 experiments, designed to support a Wemos D1 mini ESP8266 and a TFT display. The Wemos was selected here because its small footprint makes it easy to hide this microcontroller board inside buildings constructed from Lego blocks. Components of the minibench: a double-sided 60×40 mm soldering prototyping board, three 8-pin headers sockets and wires. The design, wiring scheme and the result are shown in figures 2 and 3.

Connected with an ESP32 the TFT display feels at ease. Maybe this is so because Bodmer’s TFT_eSPI library provides a User_Setup example that did not need tweaking. The display responded immediately, fast and reliable. Hardware SPI pins on the ESP32 are used for clock and data: pin 18 is connected to SCL at the display while pin 23 is connected to SDA of the display (see figure 4). The other pins breathe familiarity as well: RST of the display to D4 of the Wemos, DC to D2 and CS to pin D6. The pin on the display marked BLK remains unconnected; I noted comments on several fora that BLK may be connected to the 3.3V pin, to any pin on the ESP32 that supports pulse width modulation, or that the BLK pin can be set HIGH (backlight ON) or LOW (backlight OFF). The display at hand has no voltage regulator which implies that if one wants to use it with an Arduino Uno the precaution must be followed that control signals to the display run via voltage level conversion.

There are two major libraries supporting ST7735 controller-based TFTs: the Adafruit_GFX.h library and Bodmer’s TFT_eSPI.h library. My experience with the Adafruit_GFX.h library is that although the common graphic functions perform well, support of animations via a series of instructions ‘drawBitmap ()’ is relatively slow. Adafruit_GFX seems to be created for 160*128 displays. The library does not support the instruction ‘pushImage ()’. By contrast the TFT_eSPI.h library supports graphics as good as the GFX library while animations perform perfectly and at high speed, both with ‘drawBitmap ()’ and ‘pushImage ()’ functions. We further discuss here the TFT_eSPI library and keep Adafruit_GFX.h in storage for future experiments.

The TFT_eSPI library is different from most libraries, e.g. Adafruit_GFX and U8G2 in the sense that the ‘constructor’ is inside a special file whose name is ‘Setup_xxxx.h’ that resides in the folder ‘User_setups’. These special files are ascii which makes them endlessly tweakable with a common ascii text editor. The specific Setup_xxxx.h is called in another setup file named User_Setup_Select.h that resides in the library’s main directory. Consider Bodmer’s ‘constructor’ systematics as a kind of two-stage rocket. Both stages need to be edited befor launch. The first stage is User_Setup_Select.h and the second stage is Setup_xxxx.h. After the editing has been done successfully the display will indeed perform ‘as a rocket’!

The display was with both platforms tested with graphical tests that are available for everyone in the Arduino IDE through File → Examples, while I also ran several of my own graphical tests as well that I created c-arrays of pictures and displayed these supported by the TFT_eSPI.h library. I recommend here to upload example TFT_Meter_5 available in the TFT_eSPI library ensemble (in the Arduino IDE: File → Examples → TFT_eSPI → 160×128 → TFT_Meter_5). Brilliant!

Below follows the complete listing of ‘Setup_FW_ESP8266_ST7735_TFT_017.h’. For intimi: this is a modified Setup43_ST7735.h. I post here a screen capture because the WordPress editor has problems with the character ‘#’.

One way to demonstrate what one can do with a small display that runs animations is to make it part of a building, let’s say a shop window or something similar. Fortunately the 0.96′ display nicely fits in portrait orientation a front door in the Lego plastic building block system. So I scooped up some material from my children’s Lego assortment and constructed a Swiss chalet that features in the front door the 160*80 TFT display. This display is powered by an ESP32WROOM32. The rooms were fitted with white leds that can be switched on and off. Switching is controlled by an Arduino Nano and is completely separate from all the action happening at the front door. For the purpose of preparing Figure 5 I replaced the animation by a static 160*80 Panda bear image – “there’s a bear at the front door, mama!”.

esp32 arduino tft display factory

The component TFT supports a 2.8 inch TFT display with a resolution of 240*320 pixels.The display is not soldered on the board, but there is a 14 pin connector for a TFT display. The ILI9341 has been tested.

There are four sample projects for the Arduino IDE which could be downloaded: TFT-Box3D (download here), TFT-Graphic-Test (download here), TFT-HelloWorld (download here) and TFT-HowToUseFonts (download here). And there are two examples for the Arduino IDE for using the touch functionality which could be downloaded: TFT-TouchBtn (download here) and TFT-TouchDraw (download here).

There are two dip switches for the component: SW311 and SW314. If you want to use the TFT display all switches on SW311 have to be on on. If you additonally want to use the touchpad of the display all switch of SW314 have to be on. The following two tables shows the functions and the potential conflicts with other components

After the download it"s necessary to add both libraries to your Arduino IDE. Open Sketch > Include Library > Add .ZIP Library ... and select the downloaded archive. Do it for both libraries.

There are four sample projects for the Arduino IDE which could be downloaded: TFT-Box3D (download here), TFT-Graphic-Test (download here), TFT-HelloWorld (download here) and TFT-HowToUseFonts (download here).

And there are two examples for the Arduino IDE for using the touch functionality which could be downloaded: TFT-TouchBtn (download here) and TFT-TouchDraw (download here).

esp32 arduino tft display factory

Open Arduino IDE, find TFT_eSPI in the file and example, the T-Display factory test program is located at TFT_eSPI -> FactoryTest, you can also use other sample programs provided by TFT_eSPI

3 In the Arduino IDE tool options, select the development board ESP32 Dev Module, select Disable in the PSRAM option, select 4MB in the Flash Size option, Other keep the default

esp32 arduino tft display factory

To get the screen on the LilyGO TTGO T-display ESP32 running need the TFT_eSPI library. This is a "graphics and fonts library for ESP8266 and ESP32 processors with drivers for ILI9341, ILI9163, ST7735, S6D02A1, ILI9481, ILI9486, ILI9488, HX8357D and ST7789 based TFT displays that support SPI".

Whilst you can install the library with the Library manager of Arduino I would advise you to install the version from Github. In that way you can be sure you get the newest version. You will be able to update the library within the Library manager or overwrite the old files manually. Be sure to check whether the manual changes you have to made are still there after an update (see below at "Configure the TFT_eSPI library to use the ST7789V in the correct way")!

Manually installGo to https://github.com/Bodmer/TFT_eSPI/releases and download the Source code (ZIP) of the newest release or if you want even a newer unreleased version you can download the library by clicking on Clone or download on the upper right corner on https://github.com/Bodmer/TFT_eSPI.

Extract the top level folder of the ZIP-file to your libraries folder. When you haven"t changed your Arduino settings this folder is mostly located at C:\Users\[username]\Documents\Arduino\libraries.

Save the file TTGO_T_Display.h to the folder User_setups of the TFT_eSPI library you just installed. Most likely this will be C:\Users\[username]\Documents\Arduino\libraries\TFT_eSPI-master\User_Setups

Extract the top level folder of the ZIP-file to your libraries folder. When you haven"t changed your Arduino settings this folder is mostly located at C:\Users\[username]\Documents\Arduino\libraries.

esp32 arduino tft display factory

OpenArduino IDE,findTFT_eSPIin the file, and for example, theT-Displayfactory test program is located atTFT_eSPI -> FactoryTest, you can also use other sample programs provided by TFT_eSPI 3 In theArduino IDEtool options, select the development boardESP32 Dev Module,select Disable in the PSRAM option,select 4MB in the Flash Size option, Other keep the default