Proof-of-Concept Implementation: Web of Things-Driven On-Device Automation for Resource-Constrained Energy Devices

Read full text
Authors: Leonhard Esterbauer, Max Thoma, Tobias Schwarzinger, Thomas I. Strasser, Wolfgang Kästner
Cited by: 1

Abstract

Web of Energy: ESP32 QuickJS WoT Runtime A runtime for the ESP32 that executes JavaScript (QuickJS) logic to manage energy systems using the W3C Web of Things (WoT) standard. Features QuickJS Integration: Run modern JavaScript directly on the ESP32. WoT Runtime: Consume and interact with Thing Descriptions (TDs) from your script. EV Charger Control (V2H): Built-in logic for smart EV charging/discharging based on: Safety SoC buffers (40%). Ready-to-go scheduling (80% by 7 AM). PV Surplus capture. Market price arbitrage (Top 10% / Bottom 20% logic). Local Management API: REST endpoints on the ESP32 (Port 8080) to install, start, stop, and monitor JS “apps”. Hardware Simulation: Built-in battery model with support for real-time or accelerated simulation ticks. Project Structure /main: ESP-IDF C source code (HTTP server, WiFi, WoT bridge). /components/wot: The JavaScript runtime environment and WoT scripting layer. /spiffs: SPIFFS assets (including a built-in web UI). /benchmark: Performance measurement toolset (Rust server & Python analyzer) for RPS testing. /moddable: Benchmark client for the Moddable SDK to compare XS engine performance. controller_ev.js: The main energy management logic for the ESP32. ev_charger_mock.js: Node.js-based mock servers for Smart Meters and Market Prices. deploy_ev.js: Deployment utility to push JS logic to the ESP32. Note: Please be aware that some variable names and comments within the codebase are in German. Getting Started 1. Configure Hardware & WiFi Set up the ESP-IDF environment. Run idf.py menuconfig. Go to WiFi Configuration and set your SSID and Password. Go to WoT Runtime to adjust HTTP ports or memory limits if needed. Build and flash: idf.py build flash monitor. 2. Start Mock Services (On your PC) The ESP32 expects external WoT things (Smart Meter, Market Prices). Start the mock server: node ev_charger_mock.js Note: Ensure your PC firewall allows traffic on ports 8093-8096. 3. Deploy Control Logic Update deploy_ev.js with your PC’s IP address and the ESP32’s IP address, then run: node deploy_ev.js Control Logic Priorities The EV Charger logic (controller_ev.js) follows these priorities: 1. Safety: Keep SoC > 40% at all costs. 2. Ready-to-Go: Reach 80% SoC between 11 PM and 7 AM. 3. PV Surplus: Charge if solar export is detected. 4. Arbitrage: Discharge to the home if market prices are in the top 10% daily range. 5. Economy: Charge if market prices are in the bottom 20% daily range. API Endpoints (ESP32) GET /.well-known/wot: Root Thing Description. GET /runtime/apps: List installed JS apps. POST /runtime/apps: Install a new JS app (Raw text body). POST /runtime/apps/{id}/start: Start an app. GET /runtime/apps/{id}/logs: Retrieve console output from the JS app. Release & Maintenance To package the project for release and remove sensitive info (like WiFi credentials): ./release.sh Acknowledgments and AI Contribution Statement This project serves as a technical demonstration of automated firmware development and runtime orchestration. A significant portion of the system architecture, including the porting of the QuickJS engine to the ESP32 platform, the implementation of the W3C Web of Things (WoT) scripting layer, and the sophisticated V2H (Vehicle-to-Home) control heuristics, was developed through the collaborative orchestration of various Large Language Model (LLM) agents. The integration of the JavaScript runtime, the design of the asynchronous bridge between C and JS, and the creation of the simulated environment were generated with the assistance of AI, demonstrating the capabilities of agentic workflows in modern embedded systems engineering.

Publication details

Journal / source
Zenodo (CERN European Organization for Nuclear Research)
Publication date
21 February 2026