Skip to content
esp-cppPublic

Repository files navigation

Espressif++ (ESPP)

Modern C++ components for ESP-IDF: drivers, board support, USB, networking, ROS 2 / DDS and browser tools, ready to drop into your project.
160+ components, published one by one to the ESP Component Registry, most with a working example.

Latest release ESP Component Registry PyPI Documentation MIT license Discord

Get started · Components · Boards · Web apps · Run in QEMU · Documentation

Projects built with espp: a T-Dongle-S3 USB dongle in a Switch dock, the esp-box-emu emulator on an ESP32-S3-BOX, the tab5-emu launcher on an M5Stack Tab5, a mini retro computer on a Byte90, a 3D renderer on an ESP32-S3-BOX, and a fluid simulation on an ESP32-S3-BOX-3
Built with espp: esp-usb-ble-hid · esp-box-emu · tab5-emu · mini-retro-computer · esp-simple-3d · esp-box-fluidsim

espp is a collection of C++ components for the ESP-IDF framework. Each one is small, focused and usable on its own: add espp/timer and you get a timer, not a framework. Almost every component has an example/ project, and each has a documentation page with its API reference. Together they cover most of what an ESP32 product needs: tasks and logging, sensor and display drivers, board support for nearly 30 development boards, USB devices, Wi-Fi / Ethernet / BLE networking, ROS 2 interop, over-the-air updates, and browser tools that talk straight to your hardware.

The components are built and tested in CI with ESP-IDF v6.1 on the ESP32, ESP32-S3, ESP32-C3, ESP32-C6 and ESP32-P4. Each declares the ESP-IDF version it needs in its manifest (most need 5.x). The portable subset also builds for Linux, macOS and Windows, and ships as a Python package.

Quick start

Add a component to an ESP-IDF project with the component manager:

idf.py add-dependency "espp/timer^1.4"
#include <chrono>
#include <thread>

#include "logger.hpp"
#include "timer.hpp"

using namespace std::chrono_literals;

extern "C" void app_main(void) {
  espp::Logger logger({.tag = "app", .level = espp::Logger::Verbosity::INFO});

  // runs the callback every 500 ms on its own task; return true to stop
  espp::Timer timer({.name = "heartbeat",
                     .period = 500ms,
                     .callback = [&]() {
                       logger.info("tick");
                       return false;
                     }});

  while (true) {
    std::this_thread::sleep_for(1s);
  }
}

Other ways to start:

  • A new project: create it from the esp-cpp/template repository (the green Use this template button). It is set up for C++ and pulls espp components through the component manager.
  • Desktop C++ or Python, no ESP hardware: pip install espp, or find_package(espp) / FetchContent / CPM from CMake. See Desktop and Python.
  • Every option, including a git submodule: the Getting started guide.

What's inside

Capability Some of the components
Core & RTOS task, timer, logger, thread_pool, event_manager, state_machine, cli, coredump, system, monitor docs
Storage & configuration nvs, persistent_data (versioned settings with migrations), file_system, littlefs, sdcard docs
Buses & I/O i2c, spi, twai (CAN), rmt, adc, IO expanders (mcp23x17, aw9523, pca9535…) docs
Sensors IMUs (bmi270, icm42607, lsm6dso, qmi8658, bno055…), magnetic encoders (as5600, mt6701), multizone time-of-flight (vl53l), fuel gauges, RTCs, power monitors, GPS docs
Motor control FOC bldc_motor and drivers, bldc_haptics, pid, adrc, trajectory_planner, ODrive (odrive_ascii, odrive_native), CANopen / DS402 (canopen), Basicmicro controllers docs
Audio audio, codec docs
Displays, LEDs & haptics display + display_drivers on LVGL, led, led_strip, neopixel, drv2605, expressive_eyes docs
Input & HID touch controllers, button, joystick, usb_device (CDC, HID, MSC, WebUSB, X-Input), usb_host, hid-rp, gamepad_map, switch_pro, switch2_pro docs
Connectivity & protocols wifi, ethernet, provisioning, socket, rtsp, rtps (ROS 2 / DDS), ble_gatt_server, ota, dispatcher + stream_frame, telemetry, ftp, LoRa (sx126x, meshtastic), NFC docs
Math & DSP math, filters, esp-dsp docs
Data & serialization serialization, cdr, cobs, csv, binary-log, reflect_cpp, format docs

Highlights

  • Board support for nearly 30 boards. One-call setup for the display, touch, audio, buttons, IMU and SD card on boards from Espressif, M5Stack, LilyGo, Waveshare, Seeed, Adafruit, MotorGo and others: the ESP32-S3-BOX, M5Stack Tab5 and Cardputer, LilyGo T-Deck, Waveshare ESP32-P4 boards and more. All boards →
  • ROS 2 on a microcontroller. rtps is an RTPS / DDS stack with publishers, subscribers, services and actions that interoperates with ROS 2 nodes over Fast DDS and Cyclone DDS. CI checks it against ROS 2 Humble and Jazzy, and against an emulated ESP32 in QEMU. RTPS →
  • USB the easy way. usb_device builds composite devices (CDC serial, HID, mass storage, WebUSB vendor, X-Input) from a config struct, and usb_host reads HID devices such as gamepads, keyboards and 3D mice.
  • Browser tools for your device. Self-contained web apps talk to your hardware over WebUSB, Web Serial or WebHID, with nothing to install. The dispatcher lets one USB link serve OTA updates, crash dumps, system info and your own modules, and the Device Hub finds the right console for whatever a device runs. Browser tools →
  • Run without hardware. The qemu board package brings up the display, Ethernet and an SD card in Espressif's QEMU, for development and CI. QEMU guide →
  • Desktop and Python too. Tasks, timers, sockets, RTSP, RTPS, serialization and more run on your computer, from C++ or Python.

Browser tools

The web apps are single HTML files that talk to a device over WebUSB, Web Serial or WebHID from desktop Chrome or Edge, with nothing to install. Each espp component that has one keeps it in its web/ folder, and they are all published on the web apps page.

The espp Serial Plotter plotting a motor's target, position, velocity and current over time
Serial plotter (telemetry): live plots from CSV over a serial port, or binary telemetry over WebUSB
The espp VL53L5CX console showing an 8x8 time-of-flight frame as 3D bars and a zone grid
VL53L5CX console (vl53l): a multizone time-of-flight sensor in 3D, with its settings
The espp Gamepad Map Console showing a controller's live input before and after its button map, its profiles and the map editor
Gamepad map console (gamepad_map): live input before and after the button map, per-controller profiles
The espp System Console showing chip and firmware info, reboot controls, heap gauges and the task table
System console (system, monitor): chip and firmware info, reboot, heap and tasks

The screenshots show the published apps fed with sample data.

Desktop and Python

The portable subset of espp (tasks, timers, sockets, RTSP, RTPS, CDR, COBS, serialization, math and more) builds for Linux, macOS and Windows.

Python (espp on PyPI):

pip install espp

The python/ folder has example scripts for timers, tasks, sockets, RTSP and RTPS.

C++: link the espp::espp CMake target, which carries the include directories, the C++23 requirement and the system libraries. Install it and use find_package, or pull it in directly:

include(FetchContent)
FetchContent_Declare(espp
  GIT_REPOSITORY https://github.com/esp-cpp/espp.git
  GIT_TAG main
  SOURCE_SUBDIR lib)   # the cross-platform C++ library lives in lib/
FetchContent_MakeAvailable(espp)
target_link_libraries(my_app PRIVATE espp::espp)
# or build + install espp into a prefix (or run lib/build.sh)
cmake -S lib -B build -DESPP_INSTALL=ON -DCMAKE_INSTALL_PREFIX=/path/to/install
cmake --build build --target install
find_package(espp REQUIRED)
target_link_libraries(my_app PRIVATE espp::espp)

CPM works the same way (CPMAddPackage(NAME espp GITHUB_REPOSITORY esp-cpp/espp GIT_TAG main SOURCE_SUBDIR lib)). See lib/ for whole-archive linking, versioning and the build scripts, and pc/ for example C++ programs that use the installed package.

Built with espp

Project What it is
esp-box-emu Retro game emulators (NES, Game Boy, Genesis, MSX, Doom, Dark Forces…) on the ESP32-S3-BOX with a custom gamepad
tab5-emu Emulation and games on the M5Stack Tab5 (ESP32-P4)
esp-usb-ble-hid A USB dongle that turns Bluetooth LE gamepads into a wired Switch Pro or Xbox 360 controller, with a browser console
camera-streamer and camera-display An ESP32 TimerCam streaming MJPEG over RTSP, shown on an ESP32-S3-BOX
software-defined-haptics Software-defined haptic knobs on a BLDC motor
wireless-debug-display Plots and logs from another system, sent over UDP to an ESP32 display
mini-retro-computer A tiny retro computer on the ALXV Labs Byte90 or a Waveshare ESP32-S3 Touch LCD
esp-simple-3d A textured 3D renderer on the ESP32-S3-BOX
esp-box-fluidsim An interactive fluid simulation on the ESP32-S3-BOX, tilted with its IMU
esp-box-motor-gesture-control and esp-motorgo-mini-gesture-control ESP32-S3-BOX tilt gestures driving a MotorGo Mini's motors over ESP-NOW

Built something with espp? Tell us on Discord.

Community

Questions, ideas or something to show? Join the Discord:

espp Discord server

Bug reports and feature requests go to GitHub issues.

Contributing

To work on espp itself:

  1. Install clang-format and pre-commit, then run pre-commit install in the repository so every commit is formatted.
  2. Build a component's example from its folder, for example cd components/timer/example && idf.py build.
  3. To build the documentation locally, install Docker, build the image once with docker build -t esp-docs doc, then run ./build_docs.sh. The sources are in doc/; the published site is built by CI.

espp is released under the MIT License.

Releases

Used by

Contributors

Languages