π¨π³ δΈζηζ¬ README.zh-CN.md | πΊπΈ English Version README.md
This repository a serviceβoriented framework for embedded systems, built on ESPβIDFβ―5.4 and tested on ESP32βS3. Every function (light sensor, camera, UART, HTTP upload, BLE notifyβ¦) runs as an independent service module that autoβregisters through a service registry and communicates over a message bus. Adding a new sensor is one HAL + one service file; adding a new cloud sink is one subscriber. The same bus already fansβout data to WiβFiβ―HTTP, BLEβ―GATT and UART; hooks for MQTT, SDβcard, LoRa are ready.
| Version | Date | Highlights |
|---|---|---|
| v0.5 | 2025β05β03 | Zeroβcopy camera, binary cache, adaptive FPS, new docs |
| v0.6 | 2025β05β07 | Introduced service_registry:β’ All services now registered via service_registry_register()β’ Can be controlled under group subscription |
| v0.7 β Sink / Uploader Refactor | 2025β05β10 | β’ Added sink-callback architecture in service_registryβ’ Replaced monolithic data_uploader_service with http_uploader_serviceβ’ msg_t gains .release() hook β JPEG owner returns camera_fb_t safelyβ’ UART & HTTP now consume JSON-first β’ Only JPEG needs custom code (you can always add your own) β’ Will write a document showing how to do it |
| v0.8 β Kconfig Migration | 2025-05-20 | β’ All project settings exposed via menuconfig β’ sdkconfig.defaults shipped for one-click buildβ’ Router table (publisher β sink) selectable in UI β’ utils/config.h shrunk to a thin wrapper |
| Version | ETA | Key Changes | Delivery Criteria |
|---|---|---|---|
| v0.9Β βΒ BLE Service & OTA Refinement | 2025β06 | β’ Refactor BLE GATT layer: separate profile and service logic β’ Introduce ble_register_characteristic() APIβ’ Demo: add a custom Notify in 5 lines β’ Add How to Add BLE Characteristic doc |
* BLE unit tests cover new API * Existing Light Notify functionality remains compatible * OTA rollback |
| v1.0Β βΒ Quality Release | 2025β06 | β’ β₯β―80β―% unit test coverage (cache, encoder, msg_bus, registry, BLE API) β’ GitHub Actions: build + ctest + clang-format all passβ’ Public firmware binary + 2βmin demo video β’ Complete bilingual docs and architecture diagrams |
* CI passes all checks * CHANGELOG & release notes finalized * README features embedded demo video link |
- Auto-reconnecting Wi-Fi connection manager
- Periodic sensor readings via ADC (Analog-to-Digital Converter) or Digital Pin
- Secure HTTPS POST to cloud with JSON payloads
- Data uploader: 5-second loop by default (adaptive via RSSI)
- UART echo for sensor debugging
- BLE GATT Server: notifies mobile device with sensor data (e.g. light / JPEG hash)
- Component-based structure under
components/ - Over-the-Air (OTA) firmware update (starts 30s after boot by default)
- Camera (OV2640) JPEG capture + HTTP upload
- Message Bus
EVENT_SENSOR_JPEGfor binary frame pipeline - Zero-copy JPEG transmission (
camera_fb_t*passthrough, no memcpy) - Offline binary JPEG ring buffer with auto-retry
- Future-ready: designed for MQTT and custom sensors
- Decoupled module, can remove any pub or sub or sink
- Camera Module Deep Dive
- Bilingual Docs + Mermaid Diagrams
project-root
βββ components/
β βββ monet_hal/ # Hardware abstraction layer (ADC, UART, Wi-Fi)
β β βββ include/monet_hal/*.h
β β βββ src/*.c
β βββ monet_core/ # Core messaging infrastructure (e.g., msg_bus)
β β βββ include/monet_core/*.h
β β βββ src/*.c
β βββ net/ # Networking (HTTPS POST, future MQTT)
β β βββ include/net/*.h
β β βββ src/*.c
β βββ OTA/ # OTA update support via HTTPS
β β βββ include/OTA/*.h
β β βββ src/*.c
β βββ service/ # Business logic (FreeRTOS tasks, BLE, Uploader)
β β βββ include/service/*.h
β β βββ src/*.c
β βββ utils/ # Common tools and infrastructure
β βββ include/utils/*.h
β βββ src/*.c # json_utils, cache, log, format helpers
β
βββ main/ # Application entry point
β βββ main.c
β βββ CMakeLists.txt
β
βββ .github/workflows/ # GitHub Actions CI
β βββ ci.yml
βββ server/ # OTA test server (optional)
βββ README.md
Click the link below to view the interactive system diagram:
π System Architecture Diagram - GitHub Pages
This guide will help you build, configure, and run the ESP-MoNet project on your ESP32-S3 board.
- ESP-IDF v5.0 or higher installed and configured
- How to get ESP-IDF
- Your ESP32-S3 DevKit board (e.g. Freenova ESP32-S3 with PSRAM, if camera not used, any esp32s3 board will be good)
- A USB cable and access to serial terminal (e.g.
screen,minicom, oridf.py monitor)
-
Clone the repository
git clone https://github.com/MrRaidrop/ESP-MoNet.git cd ESP-MoNet -
Set the target chip
idf.py set-target esp32s3
-
Use provided configuration
cp sdkconfig.default sdkconfig
-
Configure and verify settings (optional)
idf.py menuconfig
Key settings (already set in
sdkconfig.default, but double-check if needed):- Wi-Fi: enabled by default (
CONFIG_WIFI_SERVICE_ENABLE) - BLE: enabled (
CONFIG_BLE_SERVICE_ENABLE)
BLE needs Bluetooth 4.2, not 5.0 (required on ESP32-S3) - Camera: enabled (
CONFIG_CAMERA_SERVICE_ENABLE)
Requires PSRAM support on ESP32-S3 and camera module (OV2640) - ADC / Light Sensor: enabled (
CONFIG_LIGHT_SENSOR_ENABLE) - msg_bus / cache / JSON / uploader modules are enabled
- Wi-Fi: enabled by default (
idf.py build flash monitorTip: Use
idf.py menuconfiganytime to enable/disable features in the Modules section.
- BLE: Connect via nRF Connect, observe sensor notify (e.g.
light_value,jpeg_frame_hash) - UART: Run
screen /dev/ttyUSB0 921600or use serial terminal to see logs - Wi-Fi: ESP32 will upload JPEG + sensor data to your configured HTTPS server
| Module | Setting |
|---|---|
| Wi-Fi | Enabled, STA mode |
| BLE | Enabled, 4.2 only (not 5.0!) |
| Camera | Enabled, PSRAM required |
| Light Sensor | Enabled |
| Logging | Info level, tag filtering enabled |
| Services | All core modules enabled (msg_bus, cache) |
Ready to go? Plug in your board, flash it, and watch the data flow.
Workflow: Firmware boots and connects to Wi-Fi
ota_test_task starts counting to 30
After 30s, it performs OTA via HTTPS:
https://<your_server_ip>:8443/firmware.bin To test OTA, build a new firmware version, host it on your server, and let the device auto-update.
For complete OTA server setup instructions, refer to:
/server/README_SERVER.mdAll sensor data is uploaded in a unified JSON format, automatically generated by the centralized encoder in json_encoder.c.
Each msg_t from the message bus is converted using json_encoder_encode() and sent via HTTP POST or BLE Notify, depending on connection status.
Example Outputs Light Sensor
{
"type": "light",
"value": 472,
"ts": 1713302934
}
DHT22 Temperature & Humidity
{
"type": "temp",
"temperature": 24.65,
"humidity": 63.10,
"ts": 1713302971
}
Unknown topic fallback
{
"type": "unknown",
"topic": 99,
"ts": 1713303001
}
Add Your Own Format
To define the format for your new sensor:
Extend the msg_t data union in msg_bus.h
Add a case in json_encoder_encode() to format the desired JSON fields for your topic.
The upload system requires no other changes β just define the message and format once.
| Feature | Status | Notes |
|---|---|---|
| Light sensor ADC driver | β Done | Reads every 1s, publishes via msg_bus |
| JSON packaging utility | β Done | Structured type + value + timestamp format |
| HTTPS POST to cloud | β Done | Modular http_post_hal() + retry support |
| BLE GATT notification | β Done | Subscribe msg_bus, notify phone via notify_raw() |
| UART forwarding (light sensor) | β Done | UART sends formatted values via msg_bus subscription |
| Upload retry (cache) | β Done | RAM ring buffer with manual flush_with_sender() |
| Modular task architecture | β Done | Each service runs as isolated FreeRTOS task |
| OTA update (Wi-Fi) | β Done | HTTPS OTA using esp_https_ota() |
| GitHub repo + documentation | β Done | Clean README, architecture diagram, GitHub Actions |
| Camera JPEG capture | β Done | OV2640 integration + camera_hal abstraction |
| Zero-copy JPEG pipeline | β Done | camera_fb_t* passed directly via msg_bus |
| Offline binary JPEG cache | β Done | flash-resident ring buffer with auto flush |
| Dynamic FPS based on RSSI | β Done | Adapts to Wi-Fi quality automatically |
| MQTT secure upload | π Planned | Add TLS MQTT broker support |
| OTA update (BLE) | π Planned | Plan to implement BLE-based OTA update |
| DMA + Ring Buffer integration | β Done | For ultrasonic / high-rate sensor support |
| Flutter mobile app (sensor UI) | π Planned | BLE dashboard for real-time sensor data |
| Flutter mobile app (BLE OTA) | π Planned | Integrated BLE OTA functionality |
| Category | Issue Description | Improvement Direction | Status |
|---|---|---|---|
| Architecture | No centralized service lifecycle manager | Add service_registry + app_init() startup logic |
β Done |
| Config System | Configs hardcoded in .c files |
Use Kconfig + NVS runtime override |
π Planned |
| Logging | LOGI/W macros used, but no module-level control | Introduce LOG_MODULE_REGISTER + per-module level |
β Done |
| Unit Testing | Only BLE utils tested in CI | Add test cases for json_utils, cache, uploader |
β³ In Progress |
| HTTPS Security | TLS certs not validated | Add CA config toggle + cert verification | NOT Planned |
| OTA Mechanism | No image validation or rollback | Add SHA256 + dual partition fallback | π Planned |
| BLE Extension | Only 1 notify char, no write command support | Extend GATT profile to support control commands | β³ In Progress |
Want to contribute or suggest improvements? Feel free to open an issue or fork this repo!
- Wi-Fi JPEG camera node with fail-safe cache
- BLE-notifying environmental monitor
- Hybrid image + sensor uploader
- Custom IoT prototype platform, easily extendable to sensors, or servo output
- Edge computing node with dynamic FPS control
- Developer-friendly OTA testbed
This guide walks you through integrating a new sensor (e.g., DHT22 for temperature/humidity) into the system.
Because this is a modular architecture, you can do this in 3 simple steps β without modifying any other services (UART, BLE, HTTP, etc.).
Click the link below to view the guide. π docs/how_to_add_sensor
Click the link below to view the guide. π docs/camera_module.md
ZeroβCopy, Adaptive & OfflineβResilient
(Dropβin for any OV2640βbased ESP32βS3 board β tested on Freenove DevKit)
MIT License β Use freely, modify, and integrate.
π οΈ Last Updated: May 20, 2025
Made with β€οΈ by Greyson Yu