Try out LVGL Pro - A complete toolkit to build, test, share, and ship UIs efficiently!
LVGL
Tutorial

Getting Started with LVGL on Arduino Using LovyanGFX

Set up LVGL in the Arduino IDE with the LovyanGFX display driver, and run your first example on the M5Stack Core Basic v2.7.

Felix BiegoFelix Biego7 min read

LVGL is a powerful open-source graphics library for creating graphical user interfaces on embedded devices. In this tutorial, we'll walk through setting up LVGL with the Arduino IDE and using LovyanGFX as the display driver.

LovyanGFX is a graphics library that supports a wide range of displays and microcontrollers, including the ESP32 family. By combining it with LVGL, we can quickly get a graphical interface running on supported hardware.

We'll use the M5Stack Core Basic v2.7 for this tutorial, but the same approach can be adapted to other supported boards.

M5Stack Core Basic v2.7 with its 2-inch display and three front buttons
M5Stack Core Basic v2.7
M5Stack Core Basic v2.7
Frequency240 MHz dual-core (ESP32-D0WDQ6-V3)
RAM520 KB SRAM
Flash16 MB
Display2.0-inch 320×240 IPS (ILI9342C)
InterfaceSPI
Peripherals
USB-C (CH9102F)Grove portsTF card slotspeaker3 buttons

1. Install the Arduino IDE#

Start by downloading and installing the Arduino IDE from the official website:

Download Arduino IDE

At the time of writing, the latest version was 2.3.10.

Once installed, launch the IDE and proceed with configuring support for ESP32 boards.

2. Install ESP32 Board Support#

The Arduino IDE does not include ESP32 board support by default, so we'll need to install it.

  1. Open the Boards Manager from the sidebar.
  2. Search for esp32.
  3. Find esp32 by Espressif Systems and click Install.
Arduino IDE Boards Manager showing the esp32 by Espressif Systems package
Installing esp32 by Espressif Systems from the Boards Manager

This package provides the necessary tools to compile and upload Arduino sketches to ESP32-based boards.

Depending on your operating system and the USB-to-serial chip used by your board, you may also need to install additional serial drivers.

3. Install LVGL and LovyanGFX#

Next, we'll install the libraries required for the example.

Open the Library Manager in the Arduino IDE and search for the following libraries:

  • lvgl - The graphics library we'll use to create the user interface.
  • LovyanGFX - The display driver library that will handle communication with the display hardware.

Install both libraries.

Using the Latest LVGL Development Version#

You can also use a custom version of LVGL instead of the one available through the Arduino Library Manager.

For example, if you want to test new features or examples that have not yet been included in an official release, you can download or clone the latest version from the LVGL GitHub repository.

lvgl/lvgl

A free and full-featured embedded UI library for small MCUs and 3D-capable MPUs. Use it directly in C, or go declarative with LVGL XML for AI integration, Figma import, live preview, and UI updates without reflashing.

C25.3k4.5k

Copy the library into your Arduino libraries directory.

Info

For this tutorial, we're using the latest LVGL master branch. At the time of writing, LVGL v9.6.0 was the latest version available through the Arduino Library Manager, but it did not yet include the LovyanGFX examples.

4. Configure LVGL#

After installing LVGL, locate its installation directory.

On most systems, the default location is:

Documents/Arduino/libraries/lvgl/

Inside this directory, you'll find a file named lv_conf_template.h.

Copy this file to the Arduino libraries directory and rename it to lv_conf.h.

Your directory structure should look like this:

Documents
      • lv_conf.h

Open lv_conf.h in a text editor.

Near the beginning of the file, change #if 0 to #if 1:

lv_conf.h
#if 0
#if 1
c

This enables the LVGL configuration file.

Enable LovyanGFX Support#

Since we'll be using LovyanGFX to drive the display, enable its integration in lv_conf.h:

lv_conf.h
#define LV_USE_LOVYAN_GFX 1
c

This tells LVGL to use the LovyanGFX integration.

5. Open the LovyanGFX Example#

Now that the libraries are installed and configured, let's open the example project.

In the Arduino IDE, navigate to:

File > Examples > lvgl > arduino > LVGL_LovyanGFX

Arduino IDE File menu open at Examples, lvgl, arduino, with LVGL_LovyanGFX selected
Opening the LVGL_LovyanGFX example

The example contains two files, which will appear as separate tabs in the Arduino IDE:

  • LVGL_LovyanGFX.ino - The main Arduino sketch that initializes LVGL and creates the example UI.
  • my_display.hpp - The LovyanGFX display configuration, which defines how the display hardware is initialized.

Because the example uses my_display.hpp, we need to tell LVGL where to find this configuration.

Add the following to lv_conf.h:

lv_conf.h
#define LV_LGFX_USER_INCLUDE "my_display.hpp"
c

This allows the LVGL integration to include our custom LovyanGFX configuration.

6. Configure the M5Stack Core Basic#

For this example, we'll use the M5Stack Core Basic v2.7, which has a 320 × 240 pixel display.

In the example sketch, configure the display resolution and rotation as follows:

LVGL_LovyanGFX.ino
#define TFT_HOR_RES   240
#define TFT_VER_RES   320
#define TFT_ROTATION  LV_ROTATION_90
c

These settings configure the display dimensions and apply a 90-degree rotation.

Configure LovyanGFX#

The M5Stack Core Basic is already supported by LovyanGFX, so we don't need to define its display pins or communication interface manually.

Open my_display.hpp.

You can either let LovyanGFX automatically detect the board using:

my_display.hpp
#define LGFX_AUTODETECT
cpp

Or explicitly select the M5Stack configuration:

my_display.hpp
#define LGFX_M5STACK
cpp

Using the predefined board configuration makes the setup much simpler, as LovyanGFX already knows how to initialize the display hardware.

7. Compile and Upload the Example#

Connect the M5Stack Core Basic to your computer using a USB cable.

In the Arduino IDE:

  1. Open the board selector and search for M5Core.
  2. Select the appropriate board from the results.
  3. Select the serial port associated with your connected device.
Tip

If you see two similar serial port entries, the one with the wch prefix may correspond to the board's USB-to-serial interface. The exact port name depends on your operating system and hardware.

Arduino IDE Select Other Board and Port dialog with M5Core and the wchusbserial port selected
Selecting the M5Core board and its serial port

Once the board and port are selected, click the Verify button (checkmark icon) to compile the project.

Alternatively, click Upload, which will compile the sketch and then flash it to the connected device.

If everything is configured correctly, the project should compile and upload successfully.

8. Run the Example#

After uploading, the board should start running the LVGL example.

You should see a button labeled "Hello Arduino!" on the display.

This confirms that:

  • LVGL has been initialized successfully.
  • LovyanGFX is communicating with the display.
  • The display resolution and rotation are configured.
  • LVGL can render graphical widgets on the device.
Info

The M5Stack Core Basic does not have a touchscreen, so the button will be visible but cannot be interacted with through touch input.

M5Stack Core Basic showing an LVGL button labeled Hello Arduino! in the center of the screen
The LVGL_LovyanGFX example running on the M5Stack Core Basic

At this point, you have a working LVGL application running on Arduino using LovyanGFX!


What's Next?#

In this tutorial, we used a board that already has a predefined configuration in LovyanGFX. This allowed us to get LVGL running without manually configuring the display interface.

However, not every development board is directly supported by LovyanGFX.

In the next tutorial, we'll look at how to use LVGL with a board that doesn't have a predefined LovyanGFX configuration, but uses display and touch controllers that are already supported by the library.

We'll explore how to configure the display interface, define the required pins, and initialize the touchscreen to create a fully interactive LVGL application.

About the author

Felix Biego
Felix Biego

Embedded UI Developer - LVGL Services

Embedded UI Developer at LVGL Services, implementing client UI designs and enabling teams to build production-ready interfaces with LVGL Pro.

Meet the people behind the blog

Discover the talented writers sharing their knowledge about LVGL

View Authors

Subscribe to our newsletter to not miss any news about LVGL. We will send maximum of 2 mails per month.

LVGL

LVGL is the most popular free and open source embedded graphics library targeting any MCU, MPU and display type to build beautiful UIs.

We also do services like UI design, implementation and consulting.

© 2026 LVGL. All rights reserved.
YouTubeGitHubLinkedIn