C++17 ESP-IDF v4.1 component with boilerplate for WiFi, MQTT, configuration, persitent storage and device info.
-
Download esp-idf v4.1. There is a handy extension for
VSCode
which installs all stuff you need. -
Add this repo as a submodule into
components
folder:cd my-esp-idf-project/ git submodule add https://github.com/lubosmato/esp32-essentials.git components/essentials/
my-esp-idf-project/ ├── components/ │ ├── essentials/ <-- │ └── ...another components... ├── main/ │ ├── CMakeLists.txt │ └── main.cpp ├── CMakeLists.txt ├── sdkconfig └── partitions.csv
-
Add binary data of web settings app and C++20 support into root
CMakeLists.txt
:cmake_minimum_required(VERSION 3.5) set(CMAKE_CXX_STANDARD 20) # <-- include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(my-esp-idf-project) target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "components/essentials/resources/web/dist/app.js.gz" TEXT) # <-- (only needed by `essentials::SettingsServer`) target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "components/essentials/resources/web/dist/index.html.gz" TEXT) # <-- (only needed by `essentials::SettingsServer`)
-
Enable exceptions in
idf.py menuconfig
-
Add
REQUIRES
into your mainCMakeLists.txt
:idf_component_register( SRCS "main.cpp" REQUIRES essentials )
-
Build
-
Inspire from examples
- Migrate to esp-idf v4.1
- Fix Esp32Storage::clear() - it mustn't clear all NVS
- Add wait for MQTT connection feature with timeout (similar as Wifi)
- Add more device info
- MQTT subscription to multi and single level (heavy feature, maybe YAGNI)
- Check all error codes and throw
- Make settings web server simpler without enormous number of route handlers
- Make settings web app smaller (overkilled by Vue.js)
- Add tests
- Use
std::span
when will be supported by esp-idf toolchain - Use
std::to_chars
andstd::from_chars
for floating point types when will be implemented in GCC