ModBee Node Web UI
A small web interface for the ModBee Node UIO: a live view of the
board's digital and analog I/O and its network, and an editor for the analog
calibration.
It reads and writes the board through NodeUioAPI, the same surface the
OpenPLC blocks use, so the page cannot disagree with the rest of the firmware
about what a value means.
What it does
- Serves a page from LittleFS at
/(data/www/). - Pushes the board state to every browser on a WebSocket at
/ws, once a
second: digital inputs and outputs, analog inputs in V or mA, analog output
counts, calibration, and the network mode, SSID and IP address. - Accepts a calibration from the page and saves it to NVS.
It does not bring a network up. Something else owns the radio, such as
uio().connect() in a sketch or the NETWORK block under OpenPLC, and this
library binds a port on whatever network is there. begin() returns false, and
update() keeps trying, until there is one.
Using it
#include <NodeUioAPI.h>
#include <NodeWebUI.h>
NodeWebUI webui(80);
void setup() {
uio().begin();
uio().connect("your-network", "your-password");
}
void loop() {
uio().update();
webui.update(); // starts serving once the network is up
}
examples/NodeWebUIBasic is the above as a sketch. running() says whether
the server has started and clients() how many browsers are on the live feed.
The page
The page lives in a LittleFS filesystem image, not in the firmware, so it is
uploaded separately. With PlatformIO, from this directory:
pio run -e lolin_s3_mini -t upload # firmware
pio run -e lolin_s3_mini -t uploadfs # the page, from data/
Without the filesystem image the WebSocket still works and the page requests
return 404.
Security
The page and the WebSocket have no authentication. Anyone who can reach the
board on the network can see its I/O and change its analog calibration. Use it
on a trusted network only.
Dependencies
- ModBeeNodeUIO, the board library in this repository
- ArduinoJson 7
- AsyncTCP
- ESPAsyncWebServer
Licence
AGPL-3.0, see LICENSE.