0

members

Easy Basics: Project 070p ESP32 development board with 1.8" SPI TFT LCD 128x160 module

of Acoptex.com in ESP8266 ESP-32

Basics: Project 070p

Project name: ESP32 development board with 1.8" SPI TFT LCD 128x160 module

Tags: ESP32 Dev Module, ESP32 development board, ESP32 Development board with WiFi and Bluetooth, ESP32-DevKitC V4 development board, ESP-WROOM-32 module with ESP32‑D0WDQ6 chip, Espressif Systems, ESP32-based development board, ESP32 modules, ESP32-WROOM-32, ESP32-WROOM-32U, ESP32-WROOM-32D, ESP32-SOLO-1, USB-UART bridge, IOT, ESP-WROOM-32 Dev Module, ESP32 DEVKITV1, Installing the ESP32 Board in Arduino IDE, Uploading sketch1.8" SPI TFT LCD, 128x160 module, SD card, ST7735R, ST7735S, Adafruit, Adafruit_ST7735, Adafruit_GFX, ST7735B, HY-1.8 SPI, S6D02A1, Adafruit_QDTech, KMR-1.8 SPI, TFT_ILI9163, Arduino Esplora, SainSmart

Attachments:  sketch1, sketch2, sketch3library 1, library2, library3

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1. ESP32 development board with WiFi and Bluetooth and USB A / micro USB B cable 1 pc

2.Arduino IDE ( you can download it from here  )

3.Jumper cables F-M, M-M

4. Breadboard half size or small size 1 pc (optional)

5. 1.8" SPI TFT LCD 128x160 module (there are quite a lot of different modules but all of them have the same working principle) 1pc

6. Resistor 5 pcs (1 - 2KOhm 4 pcs, 40 - 470 Ohm 1 pc)

General

We will learn how to connect 1.8" SPI TFT LCD 128x160 module to the ESP32 development board and use it.

There are a lot of different development boards made. You can find more information about them here

Understanding the 1.8" SPI TFT LCD 128x160 module

You can read more about it here.

Understanding the ESP32 Development board with WiFi and Bluetooth

You can read more about it here.

Signals and connections of the 1.8" SPI TFT LCD 128x160 module


This color display uses SPI to receive image data. That means you need at least 4 pins - CLOCK, DATA IN, TFT CS and D/C. If you'd like to have SD card usage too, add another 2 pins - DATA OUT and card CS. 

Note: depending on the module you’re using, the pins may be in a different order.

LITE - this is the PWM input for the backlight control. Connect to 3-5VDC to turn on the backlight. Connect to ground to turn it off. Or, you can PWM at any frequency.

MISO (or SD_MISO or SDO) (Master In Slave Out) - this is the SPI Master In Slave Out pin, its used for the SD card. It isn't used for the TFT display which is write-only

SCLK (or SD_SCK or SCK or CLK or SCL) (Serial Clock) - The clock pulses which synchronize data transmission generated by the master. This is the SPI clock input pin.

MOSI (or DIN or SD_MOSI or SDA) (Master Out Slave In) - this is the SPI Master Out Slave In pin, it is used to send data from the microcontroller to the SD card and/or TFT

TFT_CS (Chip Select or Slave Select) - the pin on each device that the master can use to enable and disable specific devices. This is the TFT SPI chip select pin

Card_CS (or SD_CS) (Chip Select or Slave Select) - the pin on each device that the master can use to enable and disable specific devices. Used if you want to read from the SD card.

D/C (or A0 or DC or RS) - this is the TFT SPI data or command selector pin

RST (or RESET or RES) - this is the TFT reset pin. Connect to ground to reset the TFT! Its best to have this pin controlled by the library so the display is reset cleanly, but you can also connect it to the Arduino Reset pin, which works for most cases.

CS (or CE or SS) (Chip Select or Slave Select) - the pin on each device that the master can use to enable and disable specific devices.

VCC - this is the power pin. Can be connected to +5VDC or +3.3VDC pin of Arduino board.

GND - ground. Connected to Arduino board GND pin.

BL (or LED+) - this is the input for the backlight control. Connect to 3.3V or 5V DC (with resistor 40-150 Ohm) to turn on the backlight.

LED - 3.3V IO and Power Supply pin

LED- - this is the backlight control ground pin. Connect to GND pin of Arduino board.

NC - Not connected. This pin is not in use.

Signals and connections of the ESP32 Development board with WiFi and Bluetooth

You can find more information (datasheets, schematics, pins descriptions, functional desgn descriptions) about each board (made by Espresiff Systems) by pressing Getting started link close to each board here.

Let's check our development board - ESP32 DEVKITV1with ESP-WROOM-32 module from Espressif Systems:

Pinout diagram for the ESP Wroom 32 breakout:

ESP32-WROOM-32 - ESP32-WROOM-32 module soldered to the development board. Optionally ESP32-WROOM-32D, ESP32-WROOM-32U or ESP32-SOLO-1 module may be soldered instead of the ESP32-WROOM-32.

USB-UART Bridge - A single chip USB-UART bridge provides up to 3 Mbps transfers rates.

BOOT button - Download button: holding down the Boot button and pressing the EN button initiates the firmware download mode. Then user can download firmware through the serial port.

EN button - Reset button: pressing this button resets the system.

Micro USB Port - USB interface. It functions as the power supply for the board and the communication interface between PC and the ESP module.

TX0, TX2 - transmit pin. GPIO pin

RX0, RX2  - receive pin.  GPIO pin

3V3 (or 3V or 3.3V) - power supply pin (3-3.6V). 

GND - ground pin.

EN - Chip enable. Keep it on high (3.3V) for normal operation.

Vin - External power supply 5VDC.

Wiring

There are two ways to wire up these displays - one is a more flexible method Software SPI (you can use any pins on the ESP32) and the other Hardware SPI is much faster (4-8x faster, but you are required to use the hardware SPI pins) 

1.8" SPI TFT LCD    ESP32 development board

LED                      3V3

SCK                      GPIO 22

SDA                      GPIO 21

A0 (DC)                GPIO 13

RESET                  GPIO 14

CS                       GPIO 12

GND                    G

VCC                    3V3

SD_CS                5

SD_MOSI            23

SD_MISO            19

SD_SCK              18

Step by Step instruction

The ESP32 is currently being integrated with the Arduino IDE like it was done for the ESP8266. There’s an add-on for the Arduino IDE that allows you to program the ESP32 using the Arduino IDE and its programming language.

1. Installing ESP32 add-on in the Arduino IDE (Windows 10 OS)

  1. Download and install the latest Arduino IDE Windows Installer from arduino.cc
  2. Download and install Git and Git GUI from git-scm.com
  3. Search for Git GUI, right-click the icon and select “Run as administrator
  4. Select the Clone Existing Repository option.
  5. Select source and destination. Source Location: https://github.com/espressif/arduino-esp32.git
  6. Target Directory:C:/Users/[YOUR_USER_NAME]/Documents/Arduino/hardware/espressif/esp32
  7. Do not create the espressif/esp32 folders, because they will be created automatically.
  8. Click Clone to start cloning the repository.Wait a few seconds while the repository is being cloned.
  9. Open the folder: C:/Users/[YOUR_USER_NAME]/Documents/Arduino/hardware/espressif/esp32/tools
  10. Right-click the get.exe file and select “Run as administrator“.
  11. You will see that necessary files will be downloaded and upzipped. It will take some time.
  12. When get.exe finishes, you should see the following files in the directory.

2. Uploading sketch to the ESP32 development board

  1. Do wiring.
  2. Plug the ESP32 development board to your PC and wait for the drivers to install (or install manually any that might be required).
  3. Open Arduino IDE. 
  4. Open Boards manager. Go to Tools -> Board -> Boards Manager… (in our case it’s the DOIT ESP32 DEVKIT V1)
  5. Select COM port that the board is attached to (if you don’t see the COM Port in your Arduino IDE, you need to install the ESP32 CP210x USB to UART Bridge VCP Drivers)
  6. Open, compile and upload the sketch1 or sketch2 or sketch3 to your ESP32 development board. If everything went as expected, you should see a “Done uploading” message. (You need to hold the ESP32 on-board Boot button while uploading).
  7. Press the ESP32 on-board EN button to reboot it. 
  8. Open the Serial Monitor at a baud rate of 115200.

Code

esp3218spitftlcdspitftbitmap. The display can load images bigger or smaller than the display size (160 x 128 px), but for better results, edit your image size to 160 x 128 px.The image should be in .bmp format. To do that, you can use a photo editing software and save the image as .bmp format. If you want to later use your own image, use an image editing tool and crop your image to no larger than 160 pixels high and 128 pixels wide. Save it as a 24-bit color BMP file - it must be 24-bit color format to work, even if it was originally a 16-bit color image - becaue of the way BMPs are stored and displayed! You can download example here. If you need to use own picture - modify the name of the bmp file in this sketch.

esp3218spitftlcdrotationtest. A simple rotation test. This code can be used for different projects.

esp3218spitftlcdgraphicstest. An advanced grafics test. This code can be used for different projects.

Summary

We have learnt how to connect 1.8" SPI TFT LCD 128x160 module to the ESP32 development board and use it.

Libraries

  • See attachments on the begining of this project
  • Adafruit_GFX library. Download, unzip  and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. You can read about it here.
  • SPI library included in your Arduino IDE.
  • Adafruit_ST7735 library. Download, unzip  and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. You can read about it here.
  • mySD library. Download, unzip  and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. You can read about it here.

Sketch

  • See attachments on the begining of this project


Other projects of Acoptex.com
Easy CBASIC Lesson 9 Compiling and debugging in Visual Studio of Acoptex.com in Csharp 10-04-2019
Easy Basics: Project 081d ESP8266 ESP-12E module and Nextion HMI display of Acoptex.com in ESP8266 ESP-12 24-03-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 22-09-2018
Viewed: 1816 times