ESP32 Manager
website·Indexed 31 days ago
https://esp32m.com/A modular, extensible, event-driven framework built on top of Espressif's native ESP-IDF. It features an on-chip responsive UI, a built-in event dispatcher with publish/subscribe capabilities, and support for MQTT and WebSockets. The framework includes core components like a Logger, Event manager, and Application container, with out-of-the-box support for peripheral devices such as Relays and H-Bridges.
What's inside ESP32 Manager
- This framework is built on top of ESP-IDF and is designed to provide a user-friendly experience similar to Arduino for rapid project kickstarting. It provides a modular, extensible, and event-driven architecture for ESP32 development.
Overview of the ESP32 Manager framework
ESP32 Manager is a C++ framework built on top of Espressif's native ESP-IDF development environment. It is designed to bridge the gap between the simplicity of Arduino and the complexity of ESP-IDF, specifically for home automation use cases. The framework provides a modular, event-driven architecture that supports true multitasking and includes built-in features such as OTA, MQTT, WiFi autoconfiguration, remote logging, JSON-based configuration/API, and real-time monitoring.Understand the ESP32 Manager architecture
ESP32 Manager is divided into two primary components:
- Core: A C++ object-oriented backend containing subsystems for logging, event management, configuration storage, bus management, device drivers, networking, I/O, debugging, Bluetooth, and an application container.
- User Interface: A NodeJS library of ReactJS components that interact with the Core's backend to visualize module states and trigger actions. The compiled UI is lightweight, consisting of
index.htmlandmain.js(under 250KB compressed).
The total compiled application size (ESP-IDF runtime + ESP32M core + UI) starts from 1.4MB.
Configure and use the esp32m Logger
The esp32m logging library allows redirecting logs from various ESP-IDF modules to multiple configurable appenders. It can intercept standard ESP-IDF logs and UART0 output.Manage GPIO pins using the io::IPin abstraction
ESP32 Manager provides an abstraction layer via theio::IPinclass to synchronize pin access, support I/O extenders (like CD74HC4067), and provide runtime information about pin capabilities (ADC, PWM, etc.).#include <esp32m/io/pins.hpp> #include <esp32m/io/gpio.hpp> // Get an IPin instance for a standard ESP32 GPIO port auto pin32 = gpio::pin(GPIO_NUM_32); // Get an IPin instance for a PCF8575 I2C extender pin #include <esp32m/io/pcf857x.hpp> auto pcf = io::usePcf8575(0x20); auto pcfPin1 = pcf->pin(1);Integrate FC-37 rain sensor
The FC-37 is a resistive rain sensor. ESP32 Manager reads the analog signal and converts it to a percentage of rainfall.#include <esp32m/io/gpio.hpp> #include <esp32m/dev/fc37.hpp> dev::useFc37(gpio::pin(GPIO_NUM_33));// UI Plugin Configuration
import { startUi, Fc37 } from "@esp32m/ui"; startUi({plugins:[Fc37()]});Implement periodic sensor polling with the Device class
The
Deviceclass (a descendant ofAppObject) is used to poll device-specific sensors periodically (typically once per second). To implement a device, extend theDeviceclass and override thepollSensors()method. Use thesensor()method to record readings.Note:
pollSensors()is called from a single dedicated thread sequentially for all devices. Avoid unnecessary delays; move lengthy operations to separate threads to prevent blocking other devices.// Override this method in your Device class virtual void pollSensors() override { // Basic reading sensor("temperature", 22.5f); // Reading with additional properties for time-series DB refinement // sensor("temperature", 22.5f, props); }Monitor real-time and historical sensor data
The framework supports sensor monitoring via its built-in UI. For historical data and advanced visualization, it integrates with Influx (for data collection) and Chronograf (for visualization). Data can also be exported to external applications via MQTT or WebSockets APIs.Get professional consulting for ESP32 Manager
Professional assistance and consulting services for the ESP32 Manager are available. For inquiries and details, contact contact@esp32m.com.Configure and use Relays in ESP32 Manager
ESP32 Manager supports single-pin (SPDT) and two-pin (latching) relays. It supports state detection via one or two extra digital pins. By default, HIGH is ON and LOW is OFF for control pins, while state pins assume LOW is ON and HIGH is OFF. Relay states are persistent across reboots by default.#include <esp32m/io/gpio.hpp> #include <esp32m/dev/relay.hpp> // Single digital pin controlled relay dev::useRelay("my-relay", gpio::pin(GPIO_NUM_XX)); // Latching relay controlled by 2 pins dev::useRelay("my-latching-relay", gpio::pin(GPIO_NUM_XX), gpio::pin(GPIO_NUM_XY)); // Latching relay with 1 state pin (ZZ) dev::useRelay("my-latching-relay", gpio::pin(GPIO_NUM_XX), gpio::pin(GPIO_NUM_XY), gpio::pin(GPIO_NUM_ZZ), gpio::pin(GPIO_NUM_ZZ)); // Latching relay with 2 state pins (ZX, ZY) dev::useRelay("my-latching-relay", gpio::pin(GPIO_NUM_XX), gpio::pin(GPIO_NUM_XY), gpio::pin(GPIO_NUM_ZX), gpio::pin(GPIO_NUM_ZY)); // Change logic level (e.g., NO/NC relay turns on via LOW) auto relay = useRelay("my-relay", gpio::pin(GPIO_NUM_XX)); relay->setOnLevel(Relay::Pin::On, false); // Disable persistence across reboots relay->setPersistent(false);Monitor sensors in real-time via the esp32m UI
Every supported sensor inesp32mhas a corresponding UI module accessible via the Devices menu. The UI widgets automatically request state updates from the backend approximately every second to provide real-time observation of sensor changes.Interact with ESP32 Manager via MQTT
The MQTT transport allows for connectionless messaging but requires each device to have a unique name.
Topic Structure: Topics follow the pattern:
esp32m/<message_type>/<project_name>/<module_task_device_name>/<sequence_optional>Message Data: The payload is a JSON-encoded string containing only the data field of the message. If no data is required, send an empty string.
# 1. Subscribe to responses mosquitto_sub -t 'esp32m/response/#' -v # 2. Publish a request (Example: get state of 'app' module in project 'basic') mosquitto_pub -t 'esp32m/request/basic/app/state-get' -m ''