esp32 display example

Esp32 Display Example: Step-by-Step Tutorial

By Michael Anderson
AD

When it comes to displays for the ESP32, options are vast and exciting. Whether you're a beginner or an experienced developer, understanding how to use them is key. Let's dive into some examples and harness the power of ESP32 for various display applications.

Before we start, ensure you have your ESP32 board ready and installed the necessary libraries. For this article, we'll use the ESP32-C3 board and the ILI9341 display library for TFT displays.

TFT Displays

TFT displays are a popular choice for ESP32 projects due to their vivid colors and graphical capabilities.

AD
Projet Paragon : Afficheur météo ESP32 | PiCockpit
Projet Paragon : Afficheur météo ESP32 | PiCockpit
ESP32 CYD with LVGL: Display Image on the Screen | Random Nerd Tutorials
ESP32 CYD with LVGL: Display Image on the Screen | Random Nerd Tutorials
GitHub - lmarzen/esp32-weather-epd: A low-power E-Paper weather display powered by an ESP32 microcontroller. Utilizes the OpenWeatherMap API.
GitHub - lmarzen/esp32-weather-epd: A low-power E-Paper weather display powered by an ESP32 microcontroller. Utilizes the OpenWeatherMap API.

Let's start with a 1.8-inch SPI TFT display - a fantastic option for space-constrained projects.

1.8-inch SPI TFT Display

First, connect the display's SPI pins to your ESP32's SPI pins (MOSI, MISO, SCLK, and CS).

ESP32 OLED Display with Arduino IDE | Random Nerd Tutorials
ESP32 OLED Display with Arduino IDE | Random Nerd Tutorials
Displaying color pictures on a 240*240 TFT screen with ST7789 controller, with an ESP32 WROOM-32
Displaying color pictures on a 240*240 TFT screen with ST7789 controller, with an ESP32 WROOM-32
ESP32/ESP8266 WIFI Display Using MQTT Protocol
ESP32/ESP8266 WIFI Display Using MQTT Protocol

Here's a sample code to initialize and display text on the TFT:

  1. Include the necessary libraries:
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
  1. Initialize the display:
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
  1. In the setup() function, initialize the display:
tft.begin();
  1. In the loop() function, display text:
tft.setCursor(0, 0);
tft.setTextColor(ILI9341_YELLOW); // Set text color to yellow
tft.setTextSize(1);
tft.print("Hello, ESP32!"));

2.4-inch TFT Display with Touch

For interactive projects, consider a TFT display with touch capabilities. A 2.4-inch display is a great balance between size and functionality.

AD

To use it, connect the display's pins as follows: SPI pins (MOSI, MISO, SCLK, and CS), touch CTP Gore, and touch GND.

an electronic device is shown in this diagram
an electronic device is shown in this diagram
a wooden frame with a weather sign on it
a wooden frame with a weather sign on it
the temperature monitor is displayed in this screenshote image, and it shows different types of
the temperature monitor is displayed in this screenshote image, and it shows different types of
Create a Stunning UI With SquareLine Studio for ESP32 Display | LVGL Tutorial
Create a Stunning UI With SquareLine Studio for ESP32 Display | LVGL Tutorial
the electronic board is displayed with an analog speedometer
the electronic board is displayed with an analog speedometer
Simple ESP32 Internet Radio with OLED Display
Simple ESP32 Internet Radio with OLED Display

Here's how to initialize and use touch functionality:

  1. Include the necessary libraries:
#include <Adafruit_FT6206.h>
  1. Initialize the touch controller:
Adafruit_FT6206 ts = Adafruit_FT6206(‘FT6206');
  1. In the setup() function, initialize the touch and display:
if (ts.begin()) {
  // Initialization failed, exit subroutine
  delay(1000);
  return;}
tft.begin();

OLED Displays

OLED displays are a great alternative for ESP32 projects needing lower power consumption and great visibility in sunlight.

AD

Let's explore an 0.96-inch SSD1306 OLED display.

GitHub - henri98/esp32-e-paper-weatherdisplay: An ESP32 and 4.2\
GitHub - henri98/esp32-e-paper-weatherdisplay: An ESP32 and 4.2\
Esp32 mini computer #diy #ideas #arduino #esp32 #viralvideo #innovation #lcd #satisfying #learning
Esp32 mini computer #diy #ideas #arduino #esp32 #viralvideo #innovation #lcd #satisfying #learning
ESP32 Display Is Worth A Thousand Words
ESP32 Display Is Worth A Thousand Words
ESP32/ESP8266 WIFI Display Using MQTT Protocol
ESP32/ESP8266 WIFI Display Using MQTT Protocol
three different types of electronic devices connected to each other, with the words display below them
three different types of electronic devices connected to each other, with the words display below them
ESP32 Cheap Yellow Display Board (ESP32-2432S028R) | Random Nerd Tutorials
ESP32 Cheap Yellow Display Board (ESP32-2432S028R) | Random Nerd Tutorials
Bluetooth System Monitor Using ESP32 + TFT Screen
Bluetooth System Monitor Using ESP32 + TFT Screen
LVGL (Light Versatile Graphics Library) ESP32 Cheap Yellow Display (ESP32-2432S028R) | Random Nerd Tutorials
LVGL (Light Versatile Graphics Library) ESP32 Cheap Yellow Display (ESP32-2432S028R) | Random Nerd Tutorials
Select Color Display for ESP32
Select Color Display for ESP32
How to Send SMS from ESP32
How to Send SMS from ESP32
ESP32 based Weatherstation
ESP32 based Weatherstation
ESP32 Photo Clock
ESP32 Photo Clock
ESP32 + SPI TFT Touch Display: Touchscreen not providing raw values
ESP32 + SPI TFT Touch Display: Touchscreen not providing raw values

0.96-inch SSD1306 OLED Display

Connect the OLED's I2C pins (SDA and SCL) to your ESP32's I2C pins.

Here's a sample code to initialize and display text on the OLED:

AD
  1. Include the necessary libraries:
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
  1. Initialize the display:
Adafruit_SSD1306 display(0x3C, OLED_RESET, SSD1306_WIDTH, SSD1306_HEIGHT);
  1. In the setup() function, initialize the display:
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  1. In the loop() function, display text:
display.setCursor(0, 0);
display.setTextColor(WHITE);
display.setTextSize(1);
display.print("Hello, ESP32!");

Now that you've explored these examples, it's time to bring your ideas to life! Happy hacking, and remember to share your creations with the community.

AD