esp32 display example

ESP32 Display Example: A Step-by-Step Tutorial

By Melissa Martin
AD

The ESP32, a low-cost, low-power system on a chip microcontroller with integrated Wi-Fi and dual-mode Bluetooth, is highly versatile and often employed in IoT applications. When it comes to displaying data or simple UIs, it's common to connect an ESP32 to an external display. Let's explore some examples and step-by-step guides to help you get started with ESP32 display projects.

In this article, we'll delve into two primary display types compatible with the ESP32: LCDs (Liquid Crystal Displays) and OLED displays. We'll cover the basic setup, libraries, and coding examples for both display types.

Liquid Crystal Display (LCD)

The ILI9341 driver-based LCDs, like the one used in the official ESP32 OLED display shield, are prevalent due to their low cost and wide availability. The ESP32's hardware SPI interface makes it easy to connect these displays.

AD
Projet Paragon : Afficheur météo ESP32 | PiCockpit
Projet Paragon : Afficheur météo ESP32 | PiCockpit
an image of a yellow and black cat on a piece of paper with the words epsp
an image of a yellow and black cat on a piece of paper with the words epsp
GitHub - G6EJD/ESP32-e-Paper-Weather-Display: An ESP32 and 2.9
GitHub - G6EJD/ESP32-e-Paper-Weather-Display: An ESP32 and 2.9

To connect your LCD, you'll need to connect the LCD's CS (Chip Select), DC (Data/Command), and LEDs (Backlight) pins to the ESP32. For the LED backlight, connect it to the ESP32's 3V3 pin using a series resistor (200-300 ohms) to limit current. Additionally, connect the LCD's MISO, MOSI, and CLK pins to the ESP32's corresponding SPI pins (GPIO12, GPIO13, and GPIO14 respectively).

Setting up the ILI9341 library

First, install the ILI9341 library by Adafruit in your Arduino IDE. In the Library Manager, search for 'ILI9341' and install the library by Adafruit. Ensure you've selected the correct board and port before uploading your sketch.

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
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.

Here's a simple example of how to initialize and display text on your LCD:

```cpp #include #include ILI9341 tft = ILI9341(&SPI, D32, D33, D25, D24, D23); void setup() { Serial.begin(115200); tft.init(); tft.fillScreen(ILI9341_BLACK); tft.setRotation(0); tft.setTextColor(ILI9341_WHITE); tft.setTextSize(2); tft.println("Hello, World!"); } void loop() {} ```

Drawing shapes and images

You can use the Adafruit GFX library to draw shapes and display images on your LCD. Here's an example of drawing a rectangle and displaying a simple bitmap:

```cpp #include #include #include ILI9341 tft = ILI9341(&SPI, D32, D33, D25, D24, D23); uint8_t bitmap[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00 }; void setup() { Serial.begin(115200); tft.init(); tft.fillScreen(ILI9341_BLACK); tft.drawRect(10, 10, 100, 100, ILI9341_GREEN); Adafruit_ImageReader reader; reader.begin(tft.width(), tft.height(), tft.width(), bitmap, sizeof(bitmap)); tft.drawBitmap(30, 30, reader.getBitmap(), reader.getWidth(), reader.getHeight(), ILI9341_RED); } void loop() {} ```

Organic Light-Emitting Diode (OLED)

OLED displays offer excellent visibility, lower power consumption, and a wider viewing angle compared to LCDs. To connect an SSD1306 or SH1106-driven OLED to your ESP32, use level shifters for the I2C signals (SDA and SCL) to protect your ESP32 from high voltages.

After connecting the OLED, install the Adafruit SSD1306 or SH1106 library and use the following example to initializing and display text on your OLED:

```cpp #include SSD1306 display(0x3c, D2, D1); // OLED display connected to I2C bus void setup() { Serial.begin(115200); display.init(); display.clearDisplay(); display.setFont(Adafruit5x7); display.setTextColor(WHITE); display.setCursor(0, 0); display.println("Hello, World!"); display.display(); } void loop() {} ```

The ESP32's versatility in handling display outputs makes it an excellent choice for various IoT projects. By exploring these examples and building upon them, you'll be well on your way to creating captivating display solutions. Happy creating!

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
ESP32/ESP8266 WIFI Display Using MQTT Protocol
ESP32/ESP8266 WIFI Display Using MQTT Protocol
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
Simple ESP32 Internet Radio with OLED Display
Simple ESP32 Internet Radio with OLED Display
ESP32-C3 Super Mini and an ILI9488 SPI TFT display
ESP32-C3 Super Mini and an ILI9488 SPI TFT display
GitHub - henri98/esp32-e-paper-weatherdisplay: An ESP32 and 4.2\
GitHub - henri98/esp32-e-paper-weatherdisplay: An ESP32 and 4.2\
Bluetooth System Monitor Using ESP32 + TFT Screen
Bluetooth System Monitor Using ESP32 + TFT Screen
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
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 based Weatherstation
ESP32 based Weatherstation
DAY 5 — ESP32 Explained | Wi-Fi & Bluetooth Microcontroller Notes
DAY 5 — ESP32 Explained | Wi-Fi & Bluetooth Microcontroller Notes
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
ESP32/ESP8266 WIFI Display Using MQTT Protocol
ESP32/ESP8266 WIFI Display Using MQTT Protocol
a black framed poster hanging on the wall
a black framed poster hanging on the wall
ESP32 + SPI TFT Touch Display: Touchscreen not providing raw values
ESP32 + SPI TFT Touch Display: Touchscreen not providing raw values
ESP32 DHT11 Weather Monitoring on TFT Touch Display
ESP32 DHT11 Weather Monitoring on TFT Touch Display
AD