1. Introduction to ESP-IDF
ESP-IDF (Espressif IoT Development Framework) is the official development framework created by Espressif Systems for its chips such as the ESP32, ESP32-S series, ESP32-C series, ESP32-H series, and ESP32-P series. It is an open-source software development toolkit based on C/C++, providing developers with comprehensive support from low-level hardware drivers to upper-level application development, and serves as the core tool for developing applications for ESP series chips.
2. ESP-IDF Environment Installation
- Download the ESP-IDF Tools Installer; offline installation is recommended.
- Offline Installation: The offline installer does not require any network connection. One installer package corresponds to only one IDF version. The installation speed is slower, but the success rate is higher.
- Online Installation: The online installer is very small and supports the installation of all ESP-IDF versions. It only downloads necessary dependency files during the installation process, but requires a stable network connection. Installation may fail if the network is poor.
2.1 Offline Installation
- After successful download, right-click the installer and select Run as administrator.
- Select the language for installation -> Accept the license agreement.
- On the environment verification page, if the "[Error] Enable Long Paths" message appears, click Apply Fix. If no error occurs, click Next.
- Choose the installation location (due to the large size of components, it is recommended to install it on a drive other than the C: drive), then click Next.
- Select the components to install (some chips are not checked by default; it is recommended to verify the selection), then click Next.
- After confirming that the installation information is correct, click Install.
- After the installation is complete, click Finish to launch ESP-IDF PowerShell and ESP-IDF CMD.
2.2 Online Installation
- After successful download, right-click the installer and select Run as administrator.
- Select the language for installation -> Accept the license agreement.
- On the environment verification page, if the "[Error] Enable Long Paths" message appears, click Apply Fix. If no error occurs, click Next.
- Select Download ESP-IDF, then click Next.
- Choose the ESP-IDF version to install and the installation directory (due to the large size of components, it is recommended to install it on a drive other than the C: drive).
-
Select the installation directory for ESP-IDF Tools, then click Next.
-
Select the components to install (some chips are not checked by default; it is recommended to verify the selection), then click Next.
-
Confirm the installation information, then click Install.
-
After the installation is complete, click Finish to launch ESP-IDF PowerShell and ESP-IDF CMD.
3. Common ESP-IDF Commands
3.1 Compilation and Flashing Process & Example
The process of compiling and flashing a project’s code typically involves:
Navigate to the project folder -> Set the chip model -> Configure the project (optional) -> Compile the project -> Flash the code.
The following demonstrates how to compile and flash the "hello_world" example:
- Open ESP-IDF CMD.
- Locate the
hello_world
folder in the ESP-IDF installation directory and navigate to it using thecd
command.
# Please modify the project path
cd H:\IDFD\Espressif\frameworks\esp-idf-v5.5\examples\get-started\hello_world
- Set the chip model.
# Set the chip model to ESP32-S3
idf.py set-target esp32s3
- Compile the project.
# Compile the project
idf.py build
- Flash the code and start the serial monitor.
# Flash the code
idf.py flash monitor
3.2 Common Commands
# Navigate to a folder
cd xxxx
# Go back to the parent directory
cd ..
# List files and folders in the current directory
dir
# Set the target ESP32 chip model
idf.py set-target esp32 # Set the chip model to ESP32
idf.py set-target esp32s3 # Set the chip model to ESP32-S3
# Access project configuration
idf.py menuconfig
# Compile the project
idf.py build
# Flash the project
idf.py flash # Attempt to flash the project using an available serial port
idf.py -p PORT flash # Flash the project using a specified serial port (replace PORT with the serial port name of your ESP32 development board)
idf.py flash monitor # Attempt to flash the project using an available serial port and print output via the serial port
idf.py -p PORT flash monitor # Flash the project using a specified serial port and print output via the serial port
# Clean compiled files
idf.py clean # Clean the compiled output files of the current project; suitable for recompiling after modifying a small amount of code to quickly clean intermediate files
idf.py fullclean # Completely clean all compiled files; suitable for after switching chip models or when encountering unusual compilation errors
# Erase flash memory
idf.py -p PORT erase-flash # Erase the entire flash memory
idf.py -p PORT erase-otadata # Erase OTA (Over-The-Air) data
4. Introduction to ESP-IDF Components
4.1 Component Overview
In addition to ESP-IDF, Espressif provides a wealth of solutions, components, and libraries, greatly facilitating developers. Examples include:
Solutions
- ESP-Insights: ESP Insights is a remote diagnostics solution that allows users to remotely monitor the health status of on-site ESP devices.
- ESP-IoT-Solution: ESP-IoT-Solution includes device drivers and code frameworks for developing IoT systems. As an additional component of ESP-IDF, it enables faster project initiation.
- ESP-NOW: A connectionless Wi-Fi communication protocol.
- ESP-SR: ESP-SR (Speech Recognition) provides basic algorithms for speech recognition applications.
- ESP-Mesh-Lite: ESP-MESH-LITE is a Wi-Fi networking application for IoT-Bridge. Based on SoftAP + Station mode, it is a Mesh solution built on top of the Wi-Fi protocol.
- ESP-WHO: ESP-WHO is an image processing development platform based on Espressif chips, containing practical development examples.
Components and Libraries
- ESP-DL: ESP-DL is a high-performance deep learning library.
- ESP-DSP: ESP-DSP (Digital Signal Processing) is the official DSP library for ESP32 and ESP32S3 chips.
- ESP-MQTT: ESP-MQTT is a Message Queuing Telemetry Transport (MQTT) protocol library for Espressif chipsets.
- ESP-NN: ESP-NN (Neural Networks) is a library containing neural network functions optimized for various Espressif chipsets.
- ESP-Modbus: The Espressif ESP-Modbus library (esp-modbus) supports Modbus communication in networks based on RS485, WiFi, and Ethernet interfaces.
- Open AI component: An OpenAI library compatible with ESP-IDF.
For more content, please visit: Espressif Development Projects
4.2 Component Installation
Note: When installing, pay attention to the IDF version requirements of the component.
The following uses "esp-iot-solution" as an example:
- Clone the repository.
git clone --recursive https://github.com/espressif/esp-iot-solution
- Compile and flash the project using the standard compilation and flashing process.