Google Chat: zj734465502@gmail.com
+86-0755-88291180
sales01@spotpear.com
dragon_manager@163.com
services01@spotpear.com
manager01@spotpear.com
WhatsApp:13246739196
ESP32-P4-WIFI6 is a multimedia development board designed by Waveshare based on ESP32-P4 with integrated ESP32-C6, and supports Wi-Fi 6 and BLE 5 wireless connections. It provides a rich set of human-machine interaction interfaces, including MIPI-CSI (integrated image signal processor ISP), MIPI-DSI, SPI, I2S, I2C, LED PWM, MCPWM, RMT, ADC, UART, TWAI, etc. Additionally, it supports USB OTG 2.0 HS, and has a built-in 40PIN GPIO expansion interface on board that is compatible with some Raspberry Pi HAT expansion boards, enabling a wider range of application adaptability. The ESP32-P4 uses a 400MHz dual-core RISC-V processor and supports up to 32MB PSRAM, featuring USB 2.0, MIPI-CSI/DSI, H.264 encoding, and other peripherals, meeting the needs for low-cost, high-performance, and low-power multimedia development. In addition, the ESP32-P4 integrates a digital signature peripheral and a dedicated key management unit to ensure data and operation security. The ESP32-P4-WIFI6 is specially designed for high-performance and high-security applications, meeting the needs of embedded systems in human-machine interaction, edge computing, and IO expansion.
1. ESP32-P4NRW32 2. ESP32-C6-MINI-1 3. 32MB Nor Flash 4. Display screen interface 5. Camera interface 6. Type-C port 7. SMD microphone | 8. Speaker interface 9. 4PIN USB port 10. ESP32-C6 UART pad 11. BOOT button 12. RST button 13. Power indicator 14. TF card slot |
This tutorial is designed to guide users to set up a software environment for ESP32-P4 hardware development, and show how to use the ESP-IDF configuration menu and compile and download the firmware to the ESP32-P4 development board through simple examples.
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 requirement | Version number requirement |
---|---|---|
esp32 by Espressif Systems | "Install Offline" / "Install Online" | ≥3.2.0 |
Library Name | Description | Version | Library Installation Requirement |
---|---|---|---|
GFX_Library_for_Arduino | GFX graphical library for SH8601 | v1.6.0 | "Install Offline" |
lvgl | LVGL graphical library | v9.3.0 | "Install Offline" is recommended |
displays | I2C driver, screen definition and touch driver | —— | "Install Offline" |
lv_conf.h | LVGL configuration file | —— | "Install Offline" |
File
-> New Sketch
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Hello, World!");
delay(2000);
}
File
-> Save As...
. In the pop-up menu, select the path to save the project, and enter a project name, such as Hello_World, click Save
①. Click to select the dropdown menu option Select Other Board and Port;
②. Search for the required development board model esp32s3 dev module and select;
③. Select COM Port;
④. Save the selection.
①. Compile the program; ②. Compile and download the program; ③. Download successful.
Demo | Basic Description | Dependency Library |
---|---|---|
HelloWorld | Demonstrates the basic graphics library function and can also be used to test the basic performance of display screens and the display effect of random text | GFX_Library_for_Arduino, displays |
Drawing_board | Touch drawing dot test | GFX_Library_for_Arduino, displays |
AsciiTable | Prints ASCII characters in rows and columns on the display screen according to the screen size | GFX_Library_for_Arduino, displays |
GFX_ESPWiFiAnalyzer | Draws the WiFi band signal strength on the screen | GFX_Library_for_Arduino, displays |
LVGLV9_Arduino | LVGL demonstration | LVGL,GFX_Library_for_Arduino, displays |
ESP-IDF (Espressif IoT Development Framework) is an open-source IoT development framework launched by Espressif specifically for the development of its ESP32 series chips. ESP-IDF provides the necessary tools and libraries to build IoT applications, including Wi-Fi, Bluetooth, peripheral drivers, file systems, network protocol stacks, encryption, security, and real-time operating systems (FreeRTOS).
The following description only applies to the VSCode + ESP-IDF environment
The best way to learn a language or development environment is to start from the basics. This section will provide a detailed guide on how to create projects, develop from existing projects, and include embedded classic tutorials such as HelloWorld and the usage of common port I2C
├── CMakeLists.txt ├── main │ ├── CMakeLists.txt │ └── main.c └── README.md
CMakeLists.txt
.idf.py add-dependency <componetsName>
to add online components to the project, which generates a idf_component.yml
file for managing components.CMake
first reads the content of the top-level CMakeLists.txt
in the project directory to read the build rules and identify the content to be compiled. When the required components and demos are imported into the CMakeLists.txt
, the compilation tool CMake
will import each content that needs to be compiled according to the index. The compilation process is as follows:When we open an ESP-IDF project, the environment is automatically loaded at the bottom. For the development of ESP32-P4-WIFI6, the bottom toolbar is also very important, as shown in the figure:
esp32p4
as the target chipAfter understanding Description of bottom toolbar of VSCode user interface, the HelloWorld project allows you to quickly get started and understand the basic projects of the ESP32 development environment. It demonstrates how to use ESP-IDF to create a basic application, and covers the ESP32 development process, including compilation, flashing, and monitor debugging steps.
HelloWorld
, set the target port and chip type (Note: There is a loading action in the lower right corner when the chip type is selected, indicating that ESP-IDF is executing the command idf.py set-target esp32p4
. It needs to pull the architecture package environment corresponding to the chip from the package manager, which may take some time. Please wait patiently. If you perform build or other operations at this time, there will be errors!!! )app_main
main function in the code, which determines the print content output through conditional judgment, and adds a loop at the end to achieve 10s restart of the chip.app_main
function is the entry point for user applications in the ESP-IDF (Espressif IoT Development Framework) development framework. It is the core function of the ESP-IDF project and is equivalent to the main function in the standard program of the C language. In ESP32 development, app_main
function is the first task scheduled by the real-time operating system (FreeRTOS), which is the starting point for the execution of the user's code.I2C is a commonly used serial communication bus, which can communicate through two lines, one data cable (SDA, Serial Data) and one clock cable (SCL, Serial Clock), and supports multi-master and multi-slave mode. On the ESP32-P4, there are two I2C bus ports. The chip internally uses a GPIO exchange matrix to configure the use of any GPIO pins. This feature allows us to freely use any GPIO as an I2C pin control. Of course, the ESP32-P4 I2C supports both Slave and Master modes. Below, we primarily use the I2C host (Master) mode for ESP32-P4 to start communication, control, send data requests or receive data from the slave devices (which can be sensors from any I2C port). The I2C pins of ESP32-P4-WIFI6 use SCL(GPIO8)
and SDA(GPIO7)
by default
In ESP-IDF, the I2C bus requires the configuration specified by i2c_master_bus_config_t
:
i2c_master_bus_config_t::clk_source
selects the source clock for the I2C bus, using the default I2C clock source (usually the default clock source) is simply set to I2C_CLK_SRC_DEFAULT
i2c_master_bus_config_t::i2c_port
sets the I2C port used by the controller, as explained above, the ESP32-P4 has two I2C ports. When two different I2C ports need to be enabled simultaneously, this needs to be utilized to distinguish between themi2c_master_bus_config_t::scl_io_num
sets the GPIO number of the serial clock bus (SCL), which is 8 on ESP32-P4-WIFI6i2c_master_bus_config_t::sda_io_num
sets the GPIO number for the serial data bus (SDA), which is 7 on the ESP32-P4-WIFI6i2c_master_bus_config_t::glitch_ignore_cnt
sets the Glitch Period for the Master Bus, and if the Glitch Period on the line is smaller than this value, it can be filtered out. Typically, this value is set to 7i2c_master_bus_config_t::enable_internal_pullup
enables internal pullups, on the ESP32-P4-WIFI6, there is already an additional I2C pullup, no need to enable internal pullupsAs described above, the I2C configuration is:
i2c_master_bus_config_t i2c_bus_config = { .clk_source = I2C_CLK_SRC_DEFAULT, .i2c_port = I2C_NUM_0, .scl_io_num = 8, .sda_io_num = 7, .glitch_ignore_cnt = 7, .flags.enable_internal_pullup = false, };
i2c_tools
the project, select the COM port and chip model, click to enter the settings. This will open a new tab: SDK Configuration editor, also known as menuconfig. Directly search for I2C in the search bar. The content has already been retrieved, and the SCL GPIO Num and SDA GPIO Num in the demo are already corresponding to SCL(GPIO8)
and SDA(GPIO7)
The ESP32-P4-WIFI6 features a 4-Wire SDIO3.0 card slot for off-chip memory expansion
In ESP-IDF, use sdmmc_host_t
and sdmmc_slot_config_t
settings to configure the default 20MHz communication frequency and 4-wire width communication, as follows:
sdmmc_host_t host = SDMMC_HOST_DEFAULT(); sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
In the design that supports 40 MHz communication, you can adjust the max_freq_khz field in the sdmmc_host_t structure to increase the bus frequency:
sdmmc_host_t host = SDMMC_HOST_DEFAULT(); host.max_freq_khz = SDMMC_FREQ_HIGHSPEED;
The SDMMC 4-wire connection on the ESP32-P4-WIFI6 should be defined as:
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT(); slot_config.width = 4; slot_config.clk = 43; slot_config.cmd = 44; slot_config.d0 = 39; slot_config.d1 = 40; slot_config.d2 = 41; slot_config.d3 = 42; slot_config.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
sdmmc
project, select the COM port and chip model, because the demo project defines the pin as a macro, so you need to configure it, of course, you can also directly fill in the pin value. Click to enter the settings, here a new tab will open: SDK Configuration editor, which is also known as menuconfig. We directly search for sd in the search bar, see that the content has been retrieved at this time, and the demo configuration has been configured, check the default initialization and create the demo file by default:The ESP32-P4 does not come with WIFI/BT capabilities by itself, whereas the ESP32-P4-WIFI6 extends its WIFI functionality by connecting to an ESP32-C6 module via SDIO. The ESP32-C6 acts as a Slave, supporting the ESP32-P4 as the Host utilizing the WIFI 6/BT 5 features through SDIO via a series of instruction sets. By adding two components, seamless use of esp_wifi
is achieved.
// In a WIFI project, add the following two components through the ESP-IDF component management tool idf.py add-dependency "espressif/esp_wifi_remote" idf.py add-dependency "espressif/esp_hosted"
wifistation
project to add componentsidf_component.yml
in the main folder of the project, which is used to manage project components, as explained in the ESP-IDF Project Catalog sectionespressif/esp_hosted: "*"
and espressif/esp_wifi_remote: "*"
have been added. They are added to the project as you build itI2S (Inter-IC Sound) is a digital communication protocol for transmitting audio data. I2S is a serial bus interface that is primarily used for digital audio data transmission between audio devices, such as digital audio processors (DSPs), digital-to-analog converters (DACs), analog-to-digital converters (ADCs), and audio codecs.
The ESP32-P4 includes 1 I2S peripheral. By configuring these peripherals, the sample data can be input and output with the help of an I2S driver. ESP32-P4-WIFI6 board integrates the es8311 Codec chip and the NS4150B power amplifier chip combination. The I2S bus and pin distribution are as follows:
Function pin | ESP32-P4-WIFI6 pin |
---|---|
MCLK | GPIO13 |
SCLK | GPIO12 |
ASDOUT | GPIO11 |
LRCK | GPIO10 |
DSDIN | GPIO9 |
PA_Ctrl (Power amplifier chip enable pin, active high) | GPIO53 |
The ESP32-P4-WIFI6 es8311 driver uses ES8311 components. It can be added during usage through the IDF Component Manager.
idf.py add-dependency "espressif/es8311"
i2scodec
project to add componentsidf_component.yml
in the main folder of the project, which is used to manage project components, as explained in the ESP-IDF Project Catalog sectionthe espressif/es8311
component has been added, and it will be added to the project when you build itecho
mode is set in the settings, the audio will be recorded by the microphone and output by the speakersESP32-P4-WIFI6 uses the ESP32-P4NRW32 chip with the following new features:
MIPI-DSI image processing can also be processed using a 2D-DMA controller, which supports PPA and JPEG encoding/decoding peripherals
esp32p4
core, and you can directly click to compile, flash, monitor. Upon completion, you can see that the screen has lit up to refresh the color bar:This example shows that the ESP32-P4 displays LVGL images through the MIPI DSI interface, which fully demonstrates the powerful image processing capabilities of the ESP32-P4
esp32p4
core, and you can directly click to compile, flash, monitor. Upon completion, you can view the screen:This example is based on ESP_Brookesia and shows an Android-like interface with many different applications. This example uses the board's MIPI-DSI port, MIPI-CSI port, ESP32-C6, TF card, and audio jack. Based on this example, you can create a use case based on ESP_Brookesia to efficiently develop multimedia applications.
idf.py add-dependency "waveshare/esp_lcd_jd9365_10_1"
to add components to your project.esp32p4
core, and you can directly click to compile, flash, monitor. Upon completion, you can view the screen:You can subscribe to this repository and raise an issue to describe your requirements. The engineers will assess your request as soon as possible: ESP32-display-support
1. This problem recurs in the case of using the VS Code plug-in, in some cases there is a bug in the ESP-IDF installed by the VS Code plug-in, and the existing solution is to change to the IDF tool to perform compilation and flashing.
1. The current SDK does not yet fully support the 400MHz frequency for the ESP32-P4 HP core. It will be updated in the ESP-IDF once the SDK is fully developed.
1. During functionality testing, we have validated several features. Some applications, like using a Cat-4 module for network access or using P4's MIPI-DSI to expand the host, are progressing but not yet stable enough to release. Once these functionalities are refined, we will add examples to the wiki.
2. If you have ideas or partially validated application scenarios, feel free to share them with us for feasibility assessment.
1. Due to stability requirements, in order for PlatformIO to support ESP32-P4, it also requires support from the PlatformIO community for the Arduino-esp32 SDK V3.1x version.
2. During development, we tested MPY firmware for ESP32-P4, which can run some basic commands. However, this is just a preliminary verification; actual interface and peripheral applications are not yet adapted. Once fully adapted and stable, we will release ESP32-P4 usage examples in MicroPython.
Monday-Friday (9:30-6:30) Saturday (9:30-5:30)
Email: services01@spotpear.com