# Interface Design and Programming Guide on ESP32-C3 with LVGL &#038; Squareline Studio

> Source: https://maker.tdlogy.com/wiki-doc/interface-design-and-programming-guide-on-esp32-c3-with-lvgl-squareline-studio/

## PROJECT OBJECTIVES:

Build a weather dashboard using SquareLine Studio software combined with the LVGL graphics library, running on TDM2517 product (using the ESP32-C3 microcontroller).

## Source code reference: Download Source Code ESP32-C3-PocketView TDM2517

## 1. PREPARE THE PROGRAMMING ENVIRONMENT AND LIBRARY

Before you start coding, you need to install all 3 tools below on your computer.

### 1.1. Arduino IDE

### 1.2. SquareLine Studio

### 1.3. Built-in Hardware Library

IMPORTANT NOTE: You are required to install (or downgrade) LVGL to version v8.3.x (e.g., 8.3.11). Never use v9.x because the command structure has changed completely and will cause compilation errors.

## 2. INTERFACE DESIGN USING SQUARELINE STUDIO

### 2.1. Project Initiation

Here you can re-customize the design to your liking.

### 2.2. Exporting Interface Files from SquareLine

## 3. CONFIGURING THE LVGL LIBRARY

LVGL is a cross-platform library so you need manual configuration to activate the system and fonts on the Arduino IDE.

### 3.1. Activate the configuration file lv_conf.h

Library folders are usually located at: C:\Users\&lt;TÊN_MÁY_TÍNH&gt;\Documents\Arduino\libraries\

// Gốc:
#if 0 /* Set this to "1" to enable content */

// Sửa lại thành:
#if 1 /* Set this to "1" to enable content */

### 3.2. Activate Fonts Used in Design

Still in the open file, enable the small font size as follows:lv_conf.h

// Gốc:
#define LV_FONT_MONTSERRAT_10 0
#define LV_FONT_MONTSERRAT_14 0

// Sửa lại thành:
#define LV_FONT_MONTSERRAT_10 1
#define LV_FONT_MONTSERRAT_14 1

Press Ctrl + S to save the file, and then close Notepad.

## 4. SOURCE CODE EXPORT AND PATH ERROR HANDLING

NOTE: Only follow this step if you have already re-exported the graphics library, if using the sample code we provide, skip this step, as the template folder structure is already set up.

### 4.1. Fixing Directory Structure Errors (Compilation Errors)

By default, the Arduino IDE requires all files to be located at the same folder level. Do the following so that the compiler does not report a missing file error:

// 1. Trong file ui.h, sửa liên kết lõi LVGL:
#include "lvgl/lvgl.h"   // Xóa dòng này
#include &lt;lvgl.h&gt;        // Thay bằng dòng hệ thống này

// 2. Trong file ui_Screen1.c, sửa liên kết lùi cấp:
#include "../ui.h"       // Xóa dòng này
#include "ui.h"          // Thay bằng dòng ngang cấp này

## 5. CONFIGURE THE WEATHER API FROM OPENWEATHERMAP

To obtain actual temperature and humidity data, the project uses the service of OpenWeatherMap.

Paste the copied API Key into the correct place in the code:

const String apiKey = "THAY_API_CUA_BAN_VAO_DAY";

Finally, edit the WiFi SSID and password declaration to your network information:

const char* ssid = "THAY_TEN_WIFI_CUA_BAN_VAO_DAY";
const char* password = "THAY_MAT_KHAU_WIFI_VAO_DAY";