High-performance serial-to-web bridge for ESP32 and embedded debugging workflows
WebSerialSim provides a robust web-based serial monitor for embedded systems. It streams Serial output to a browser using SSE, captures history in RAM/PSRAM/SD, supports command parsing, and allows custom callbacks for remote control and diagnostics.
Embedded debugging is often limited to a local USB console. WebSerialSim solves that by turning your device into a remote serial monitor over WiFi.
- a lightweight serial terminal over HTTP
- a live stream of logs to the browser
- a history buffer with optional file persistence
- a command processor for runtime control
- a drop-in Print-based interface that works like Serial
| Aspect | Serial Monitor | WebSerialSim |
|---|---|---|
| Remote access | ❌ | ✅ |
| Browser access | ❌ | ✅ |
| Persistent history | ❌ | ✅ |
| Live log streaming | ✅ | ✅ |
| Buffer management | ❌ | ✅ |
| Command parsing | ❌ | ✅ |
| Remote diagnostics | ❌ | ✅ |
Designed for ESP32 firmware debugging, telemetry, and long-running device inspection.
- Serial-to-web bridge over SSE
- Remote command execution
- Circular history buffer in RAM / PSRAM / filesystem
- Configurable timestamping
- File-based history storage for persistence
- Built-in web view and download routes
- Callback interfaces for custom logic or BLE
- Works as a
Printsubclass, so it behaves like standard Serial in many cases
WebSerialSim supports different storage backends depending on your build configuration:
SDSD_MMCLittleFSSdFat
It can also use PSRAM when available, with graceful fallback to SRAM.
Add the library to your project:
#include <WebSerialSim.h>Or copy the files from src/ into your Arduino/PlatformIO project.
#include <Arduino.h>
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
#include "WebSerialSim.h"
AsyncWebServer server(80);
WebSerialSim serialSim;
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_AP);
WiFi.softAP("WebSerialSim", "12345678");
serialSim.begin(&server);
server.begin();
}
void loop() {
serialSim.taskList();
delay(1);
}Then open:
http://<device-ip>/serial
The library accepts commands from Serial, HTTP, or external input.
TIMESTAMP ON
TIMESTAMP OFF
HISTORY ON
HISTORY OFF
HISTORY CLEAR
HISTORY INFO
HISTORY LOAD
CONFIG FS
CONFIG NOFS
CONFIG PSRAM
CONFIG NOPSRAM
CONFIG 4000
Examples:
- enable file logging
- disable file logging
- set buffer size to 4000 bytes
- toggle PSRAM usage
| Route | Method | Purpose |
|---|---|---|
/serial |
GET | Web UI for live monitoring |
/events/serial |
GET | SSE serial stream |
/buffer?action=view |
GET | View stored history |
/buffer?action=down |
GET | Download history |
/delhistory |
GET | Remove history file |
/parsingCmd |
POST | Send command payload |
The library supports two timestamp strategies:
#define TIMESTAMP_REALTIMEUses time() and wall-clock time.
Default behavior uses millis() to generate a lightweight time value without extra RTC setup.
This is useful when:
- you want very low overhead
- the device is not synchronized to a real time source
- you want timestamp generation with minimal CPU cost
History can be stored in:
- RAM
- PSRAM
- filesystem-backed storage
- direct-to-file mode when buffer is disabled
The library uses a circular buffer pattern and flushes history intelligently before overwrite.
webSerial.setbuffer(4096);
webSerial.setHistoryFile(true);
webSerial.setPSRAM(true);The implementation is designed for high-throughput serial monitoring.
Validated characteristics include:
- sustained high-volume serial output
- SSE-based delivery without blocking the main loop
- large sequential log streams without requiring WebSocket infrastructure
- stable operation in embedded multitask workflows
void begin(AsyncWebServer* mainServer);
void taskList();
void setCallback(CallbackFunzione cb);
void setCallBLE(CallbackBLE cb);
void setbuffer(size_t bytes);
void setHistoryFile(bool enable);
void setPSRAM(bool enable);
void setTimestamp(bool enable);
void echoOnOff(bool onoff);
void infoSerBuf();WebSerialSim also derives from Print, so it supports standard print operations.
void handleCommand(char* cmd) {
Serial.printf("CMD: %s\n", cmd);
}
void setup() {
webSerial.setCallback(handleCommand);
}For a serial monitor, the output is mostly unidirectional: device → browser. SSE is a better fit because it is:
- simpler
- lighter
- easier to integrate with HTTP server routing
- reliable for large continuous logs
- well-suited to browser streaming without binary protocol overhead
This keeps the implementation smaller and more stable for continuous log monitoring.
- verify WiFi access point is running
- confirm
/serialroute is served - make sure
server.begin()is called - check Serial output from the ESP32 itself
- check filesystem backend is enabled
- ensure adequate free memory
- run
HISTORY INFOto inspect state
Attenzione buffer too small ..almeno 1500
Increase the history buffer size using:
webSerial.setbuffer(4096);The library intentionally separates responsibilities:
insBuffer()handles history accumulation into the memory bufferfregbuffer()handles snapshot persistence to filesystembegin()sets up the web routes and SSE streamtaskList()keeps the internal state machine active
This keeps the code modular and easier to maintain in embedded firmware.
MIT License.
See the LICENSE file for details.
Planned enhancements are focused on stability and usability rather than protocol churn:
- improved command validation
- more detailed buffer diagnostics
- richer web UI panels
- broader filesystem backend coverage
- better release packaging for library usage
WebSerialSim is built for practical firmware diagnostics and field debugging. It aims to give embedded developers a simple, reliable way to inspect device output remotely without adding heavy infrastructure.
If you need a browser-based serial monitor for ESP32 projects, this library is designed to be a fast and lightweight option.