Designing Embedded Web Device Dashboards
Embed the dashboard on the device for a browser-only, zero-install UI. Pick from CGI, SSI, WebSockets, or REST API that best balances resource budget and user experience.
Join the DZone community and get the full member experience.
Join For FreeOverview
A web dashboard serves as the “front panel” for an embedded product — whether that product is a rack-mounted industrial controller, a bike-mounted GPS tracker, or a battery-powered soil-moisture sensor buried in a greenhouse bed. Because the dashboard is delivered over plain HTTP(S) and rendered in any modern browser, users do not have to download a native app, install drivers, or worry about operating-system compatibility; the interface is as portable as a URL. Typical tasks include:
- Toggling outputs (relays, MOSFETs, LEDs)
- Inspecting live data such as temperature, humidity, current draw, or RSSI
- Adjusting parameters like Wi-Fi credentials, alarm set-points, sampling rates
- Collecting diagnostics like log files or memory statistics for field support staff
Implementation Approaches
Embed an HTTP server — Mongoose, lwIP-HTTPD, MicroPython’s uHTTPD, or a hand-rolled socket handler - inside the firmware. Then choose, or mix, the patterns below. Each technique sits at a distinct point on the scale of resource cost versus user-experience richness.
1. CGI (Common Gateway Interface)
Classic CGI ties a URL such as /led.cgi to a firmware function that executes and returns HTML:
int cgi_led(struct http_request *r){
bool on = gpio_toggle(LED);
http_printf(r,"<h1>LED %s</h1>", on ? "ON":"OFF");
return 200;
}
- Pros: Footprint under 4 kB flash and a few hundred bytes of RAM.
- Cons: Every interaction forces a full page refresh, so UX feels clunky. Validation is manual.
2. RESTful API (Representational State Transfer)
REST treats device features as resources:
GET /api/led → read state
POST /api/led {"on":1} → set state
GET /api/adc/3 → read channel 3
The dashboard becomes a single-page app delivered from /index.html; JavaScript fetch() calls the API and patches the DOM.
- Pros: Clear separation of data and presentation; easy to reuse endpoints in a mobile app or cloud shim.
- Tips: Version your URIs (/v1/...) and compress payloads.
3. Server-Side Includes (SSI)
SSI injects runtime values into static HTML. Tokens like the following are swapped out by a callback before the file is sent.
<h2>Temp: <!--#getTemp-->°C</h2>
- Pros: dead-simple way to inject a few dynamic numbers.
- Cons: limited once you need richer interactivity.
- When to use: Read-heavy dashboards that refresh every few seconds.
- Limits: Tokens only inject text; they cannot change style or handle clicks.
4. WebSockets
WebSockets upgrade the HTTP connection to full duplex, letting both sides push frames whenever they like - ideal for streaming vibration data or ticker-style logs.
Typical flow: the dashboard loads, JavaScript calls new WebSocket("wss://device-ip/ws"), firmware keeps the socket handle, and an ISR queues sensor frames.
- Pros: Latency < 10 ms, supports binary frames for efficiency.
- Cons: Each open socket eats buffers; TLS roughly doubles RAM cost.
5. MQTT Over WebSockets
If the firmware already speaks MQTT, bridge the broker over wss://device-ip/mqtt. JavaScript clients such as Eclipse Paho can then subscribe and publish.
Example topic map:
data/temperature → periodically published by device
cmd/led → written by dashboard; MCU subscribes
- Pros: Reuses existing infrastructure; offline mode works because the broker is onboard.
- Cons: Extra protocol headers inflate packets; QoS handshakes add chatter.
Comparing Footprints and Performance
Approach | Flash | RAM | Latency | UX |
---|---|---|---|---|
CGI |
3 - 8 kB |
<1 kB |
>200 ms |
* |
SSI |
4 - 10 kB |
~1 kB |
150 ms |
** |
REST |
8 - 25 kB |
2 - 4 kB |
80 ms |
*** |
WS |
18 - 40 kB |
4 - 8 kB |
<10 ms |
***** |
MQTT/WS |
25 - 60 kB |
6 - 12 kB |
15 ms |
**** |
Securing the Dashboard
- Transport security: Serve everything over TLS; many MCUs include hardware AES, keeping overhead modest.
- Authentication: Use a signed, time-limited token instead of basic auth.
- Validation: Treat query strings and JSON bodies as hostile until parsed and bounds-checked.
- Rate limiting: Guard against runaway polling that can starve the CPU.
Many defences can be compiled out for development builds to save RAM, then re-enabled for production firmware.
Blending Techniques
Real products rarely stick to a single pattern. A popular recipe involves delivering the SPA shell, exposing low-frequency configuration through REST, streaming high-rate metrics over WebSockets, and maintaining an SSI “fallback” page for legacy browsers. This hybrid keeps memory use modest while giving power users a slick, low-latency UI.
Selecting a Strategy
A quick rule: If you need millisecond-level telemetry, pick WebSockets; if you want integration with phone apps or cloud dashboards, use REST; and if you are squeezed for flash, fall back to CGI or SSI. Transitioning later is painless because the same embedded server can host multiple schemes side by side.
Conclusion
Implementing a device dashboard using an embedded web server offers a scalable, browser-based control panel for embedded systems. Techniques such as CGI, SSI, REST APIs, and WebSockets cater to different device capabilities and complexity requirements. For modern applications, REST APIs strike a balance between simplicity and power, making them ideal for implementing features like an embedded web dashboard.
By choosing the right implementation approach and utilizing a lightweight embedded web server, developers can craft efficient, interactive, and user-friendly dashboards to control and monitor embedded devices.
For a hands-on walkthrough, see a step-by-step simple REST API implementation (LED Toggle Example). This walks through a minimal example of building an embedded web dashboard using a REST API served by an embedded web server.
You can also try Mongoose Wizard to create your WebUI dashboard in minutes. It is a no-code visual tool that enables developers to effortlessly build a professionally looking device dashboard (WebUI) and REST API without writing any frontend code. Transforming the MCU board into a browser-accessible web dashboard for control, monitoring, and updates. Whether for prototyping or building production devices, integrating a web dashboard into firmware gives end users intuitive and powerful control.
Opinions expressed by DZone contributors are their own.
Comments