Starter project for developing firmware in VSCode for ESP32 system-on-chips (SoCs).
This project provides a modern C++20 foundation for ESP32 development with WiFi provisioning, HTTP server, CLI interface, and comprehensive tooling support.
- Features
- Prerequisites
- Quick Start
- Project Structure
- Configuration
- Building and Flashing
- Development Workflow
- Debugging
- Contributing
- Modern C++20 development environment
- WiFi Provisioning with SoftAP scheme
- HTTP Server with custom handlers
- Interactive CLI with command menu system
- Logging with formatted output using espp components
- OTA Updates support
- Development Container for consistent environment
- Automated Scripts for building, flashing, and monitoring
- Static Analysis with clang-tidy integration
- Component Management with ESP Component Registry
- ESP32, ESP32-S2, ESP32-S3, or ESP32-C3 development board
- USB cable for programming and serial communication
If using the dev container (recommended):
If setting up locally:
- ESP-IDF v5.0+
- Python 3.8+
- Git
-
Clone the repository:
git clone https://github.com/samiralavi/ESP32-VSCode-starter.git cd ESP32-VSCode-starter
-
Open in VS Code:
code .
-
Reopen in Container:
- VS Code will prompt to reopen in container, or
- Press
Ctrl+Shift+P
β "Dev Containers: Reopen in Container"
-
Prepare the environment:
./scripts/prepare_environment.sh
-
Build the project:
./scripts/build_firmware.sh
-
Flash to your ESP32:
./scripts/flash_firmware.sh
-
Monitor serial output:
./scripts/monitor_serial.sh
-
Install ESP-IDF: Follow the official ESP-IDF installation guide
-
Clone and setup:
git clone https://github.com/samiralavi/ESP32-VSCode-starter.git cd ESP32-VSCode-starter source $IDF_PATH/export.sh ./scripts/prepare_environment.sh
-
Build and flash:
idf.py build idf.py flash monitor
ESP32-VSCode-starter/
βββ main/ # Main application source code
β βββ main.cpp # Application entry point
β βββ app.cpp/.h # Main application logic
β βββ http_handlers.cpp/.h # HTTP server endpoints
β βββ blufi.cpp/.h # BluFi provisioning (optional)
β βββ board.cpp/.h # Board-specific configuration
β βββ utils.cpp/.h # Utility functions
β βββ www/ # Web assets (if any)
βββ components/ # Custom components
β βββ activecpp/ # ActiveC++ component integration
βββ managed_components/ # ESP Component Registry dependencies
βββ scripts/ # Build and development scripts
β βββ build_firmware.sh # Build the firmware
β βββ flash_firmware.sh # Flash firmware to device
β βββ monitor_serial.sh # Monitor serial output
β βββ prepare_environment.sh # Setup development environment
β βββ run_clang_tidy.sh # Run static analysis
βββ containers/dev/ # Development container configuration
βββ CMakeLists.txt # Main CMake configuration
βββ sdkconfig.defaults # Default ESP-IDF configuration
βββ partitions.csv # Flash partition table
Edit the configuration in main/Kconfig.projbuild
or use idf.py menuconfig
:
idf.py menuconfig
Key configurations:
- Device ID: Unique identifier for your device
- MAC Address: Device MAC address
- WiFi Password: Default WiFi password for provisioning
- SSID Prefix: Prefix for the device's AP mode SSID
Modify CMakeLists.txt
to add or remove ESP-IDF components:
set(COMPONENTS
main esptool_py activecpp wifi_provisioning esp_http_server cxx
# Add your components here
)
# Build firmware
./scripts/build_firmware.sh
# Flash firmware to device
./scripts/flash_firmware.sh
# Monitor serial output
./scripts/monitor_serial.sh
# All-in-one: build, flash, and monitor
./scripts/build_firmware.sh && ./scripts/flash_firmware.sh && ./scripts/monitor_serial.sh
# Configure target (ESP32/ESP32-S2/ESP32-S3/ESP32-C3)
idf.py set-target esp32s3
# Configure project
idf.py menuconfig
# Build
idf.py build
# Flash
idf.py flash
# Monitor
idf.py monitor
# Combined flash and monitor
idf.py flash monitor
- Create source files in
main/
directory - Update CMakeLists.txt in
main/
to include new files - Add component dependencies in root
CMakeLists.txt
if needed - Build and test your changes
-
ESP Component Registry:
idf.py add-dependency "espressif/component_name"
-
Local components:
- Add to
components/
directory - Include in
EXTRA_COMPONENT_DIRS
in root CMakeLists.txt
- Add to
Run static analysis:
./scripts/run_clang_tidy.sh
./scripts/monitor_serial.sh
# or
idf.py monitor
In sdkconfig.defaults
or via menuconfig:
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
CONFIG_LOG_MAXIMUM_LEVEL_DEBUG=y
# Start GDB server (in another terminal)
openocd -f board/esp32-wrover-kit-3.3v.cfg
# Start GDB session
xtensa-esp32-elf-gdb build/esp32_starter.elf
Once flashed and running:
-
WiFi Provisioning:
- Device creates AP with SSID:
ACTIVECPP_<device_id>
- Connect and provision WiFi credentials
- Device creates AP with SSID:
-
Web Interface:
- Access via device IP after WiFi connection
- HTTP server provides REST endpoints
-
CLI Interface:
- Available via serial console
- Interactive command system with help
- Fork the repository
- Create a feature branch
- Make your changes
- Run clang-tidy:
./scripts/run_clang_tidy.sh
- Test your changes
- Submit a pull request
This project is licensed under the terms specified in the LICENSE file.
Happy ESP32 Development! π