Google Chat: zj734465502@gmail.com
+86-0755-88291180
sales01@spotpear.com
dragon_manager@163.com
services01@spotpear.com
manager01@spotpear.com
WhatsApp:13246739196
ESP32-S3-AMOLED-1.91 currently provides two development tools and frameworks, Arduino IDE and ESP-IDF, providing flexible development options, you can choose the right development tool according to your project needs and personal habits.
This chapter introduces setting up the Arduino environment, including the Arduino IDE, management of ESP32 boards, installation of related libraries, program compilation and downloading, as well as testing demos. It aims to help users master the development board and facilitate secondary development.
Board name | Board installation requirements | Version number requirements |
---|---|---|
ESP32-S3-AMOLED-1.91 | "Install Offline" / "Install Online” | 3.0.7 and above |
Library Name | Description | Version | Library Installation Requirements |
---|---|---|---|
LVGL | Graphical library | v8.4.0 | "Install Offline” |
Demo | Basic Description | Dependency Library |
---|---|---|
ADC | Read the current voltage value of the system | - |
I2C_QMI8658 | Print the original data sent by the IMU | - |
LVGL | LVGL demo | LVGL |
SPI_SD | Load and display the information of the TF card | - |
WIFI_STA | Set to STA mode to connect to WiFi and obtain an IP address | - |
WIFI_AP | Set to AP mode to obtain the IP address of the access device | - |
Arduino_Playablity | Playability program demo | - |
Hardware connection
Code analysis
adc_bsp_init(void)
: Initializes ADC1, including creating an ADC one-time trigger unit and configuring channel 0 for ADC1.adc_get_value(float *value,int *data)
: Reads the value of ADC1 channel 0 and calculates the corresponding voltage value based on the reference voltage and resolution, stores it at the position where the incoming pointer points to, and stores 0 if the read fails.adc_example(void* parmeter)
: After initializing the ADC, in an infinite loop, read the value of the ADC channel on GPIO1, print the original ADC value, and calculate the system voltage value, performing this operation once every second.Result demonstration
Hardware connection
Code analysis
qmi8658c_example(void* parmeter)
: The function initializes the QMI8658 device, reading and printing accelerometer data, gyroscope data, and temperature data in an infinite loop, once every second. During the rotation of the board, the gyroscope data increases with greater rotation speed, and the accelerometer calculates the corresponding acceleration based on the current position.Result demonstration
Hardware connection
Code analysis
For LVGL, lvgl_conf.h is its configuration file, and below are explanations for some commonly used contents.
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
#define LV_COLOR_DEPTH 16//Color depth, a macro definition that must be concerned with porting LVGL
#define LV_MEM_CUSTOM 0
#if LV_MEM_CUSTOM == 0
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
#define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
#define LV_MEM_ADR 0 /*0: unused*/
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
#if LV_MEM_ADR == 0
#undef LV_MEM_POOL_INCLUDE
#undef LV_MEM_POOL_ALLOC
#endif
#else /*LV_MEM_CUSTOM*/
#define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
#define LV_MEM_CUSTOM_ALLOC malloc
#define LV_MEM_CUSTOM_FREE free
#define LV_MEM_CUSTOM_REALLOC realloc
#endif /*LV_MEM_CUSTOM*/
//The above section is mainly for LVGL memory allocation,
//which defaults to lv_mem_alloc() versus lv_mem_free().
There are also some LVGL demos and file systems that can be set in the conf configuration file.
Code modification
EXAMPLE_USE_TOUCH
in the file where the main function is located, and change 1
to 0
EXAMPLE_USE_TOUCH
in the file where the main function is located, and change 0
to 1
#define EXAMPLE_USE_TOUCH 0
Result demonstration
The LVGL demo has high requirements for RAM and ROM, so it is necessary to configure the demo according to the requirements of environment setup, and after the program is flashed, the running effect of the device is as follows (if it is a board with touch, you need to modify the macro definition EXAMPLE_USE_TOUCH to 1):
Hardware connection
Code analysis
SD_card_Init(void)
: This function initializes the TF card according to different configurations, including configuring the mounting parameters, host and card slot parameters, and then tries to mount the TF card, if successful, the card information and capacity are printed.Result demonstration
Hardware connection
Code modification
The project realizes that the chip is connected to WIFI in STA mode and obtains the IP address, before compiling and downloading the firmware, some code needs to be modified, specifically changing the name and password of the WIFI router to those suitable for the environment.
Code analysis
wifi_init(void)
: This function is used to initialize the Wi-Fi connection of the ESP32. It sets the ESP32 to Wi-Fi site mode and tries to connect to the specified Wi-Fi network (via the ssid
and password
). If the connection is successful, it prints the local IP address; if the connection fails within a certain period (20 * 500 milliseconds), it prints the connection failure message. At the same time, the function can also set the auto-connection and auto-reconnect functions.Result demonstration
Hardware connection
Code analysis
const char* ssid = "bsp_esp_demo";
const char* password = "waveshare";
WiFi.softAP(ssid,password);
Result demonstration
Hardware connection
Result demonstration
This chapter introduces setting up the ESP-IDF environment setup, including the installation of Visual Studio and the Espressif IDF plugin, program compilation, downloading, and testing of example programs, to assist users in mastering the development board and facilitating secondary development.
Demo | Basic Description | Dependency Library |
---|---|---|
ADC | Read the current voltage value of the system | - |
I2C_QMI8658 | Print the original data sent by the IMU | - |
LVGL | LVGL demo | LVGL |
SPI_SD | Load and display the information of the TF card | - |
WIFI_STA | Set to STA mode to connect to WiFi and obtain an IP address | - |
WIFI_AP | Set to AP mode to obtain the IP address of the access device | - |
FactoryProgram | Comprehensive project | LVGL |
Hardware connection
Code analysis
adc_bsp_init(void)
: Initializes ADC1, including creating an ADC one-time trigger unit and configuring channel 0 for ADC1.adc_get_value(float *value)
: Reads the value of ADC1 channel 0 and calculates the corresponding voltage value based on the reference voltage and resolution, stores it at the position where the incoming pointer points to, and stores 0 if the read fails.adc_example(void* parmeter)
: After initializing the ADC, in an infinite loop, read the value of the ADC channel on GPIO1, print the original ADC value, and calculate the system voltage value, performing this operation once every second.Result demonstration
After the demo is flashed, the running result of the device is as follows:
Hardware connection
Code analysis
qmi8658c_example(void* parmeter)
: The function initializes the QMI8658 device, reading and printing accelerometer data, gyroscope data, and temperature data in an infinite loop, once every second.Result demonstration
After the demo is flashed, the running result of the device is as follows:
Hardware connection
Code analysis
① and ②: There is a difference in the number of pixels
in the horizontal and vertical directions
③ and ④: The register at the 0x36
address under the lcd_init_cmds array is responsible for rotation, and modifying its value can achieve a rotation effect. If no rotation is needed, you can directly delete {0x36,(uint8_t []){0xF0,1,0}}
Code modification
EXAMPLE_USE_TOUCH
in the file where the main function is located, and change 1
to 0
EXAMPLE_USE_TOUCH
in the file where the main function is located, and change 0
to 1
#define EXAMPLE_USE_TOUCH 0
Result demonstration
Hardware connection
Code analysis
SD_card_Init(void)
: This function initializes the TF card according to different configurations, including configuring the mounting parameters, host and card slot parameters, and then tries to mount the TF card, if successful, the card information and capacity are printed.Result demonstration
Hardware connection
Code analysis
espwifi_Init(void)
: This function is used for WiFi initialization on ESP32. It sequentially initializes non-volatile storage, the TCP/IP stack, creates a default event loop and a default WiFi site network interface, initializes WiFi with the default configuration, registers event handlers to handle WiFi and IP-related events, sets WiFi connection parameters, and starts WiFi.Code modification
The project realizes that the chip is connected to WIFI in STA mode and obtains the IP address, before compiling and downloading the firmware, some code needs to be modified, specifically changing the name and password of the WIFI router to those suitable for the environment.
Result demonstration
After the demo is flashed, the running result of the device is as follows:
* The chip successfully connects to WIFI and obtains an IP address while in STA mode.
Hardware connection
Code analysis
wifi_init_softap(void)
: This function is used to initialize the ESP32's Wi-Fi soft access point, including setting up the network interface, registering event handling functions, configuring soft AP parameters, and starting the soft AP.Result demonstration
Hardware connection
Code modification
EXAMPLE_USE_TOUCH
in the file where the main function is located, and change 1
to 0
EXAMPLE_USE_TOUCH
in the file where the main function is located, and change 0
to 1
#define EXAMPLE_USE_TOUCH 0
Result demonstration
①View through Device Manager: Press the Windows + R keys to open the "Run" dialog box; input devmgmt.msc and press Enter to open the Device Manager; expand the "Ports (COM and LPT)" section, where all COM ports and their current statuses will be listed.
②Use the command prompt to view: Open the Command Prompt (CMD), enter the “mode” command, which will display status information for all COM ports.
③Check hardware connections: If you have already connected external devices to the COM port, the device usually occupies a port number, which can be determined by checking the connected hardware.
①Use the dmesg command to view: Open the terminal.
①Use the ls command to view: Enter ls /dev/ttyS* or ls /dev/ttyUSB* to list all serial port devices.
③Use the setserial command to view: Enter setserial -g /dev/ttyS* to view the configuration information of all serial port devices.
Monday-Friday (9:30-6:30) Saturday (9:30-5:30)
Email: services01@spotpear.com