Terminal Widget
The Terminal widget displays a scrolling log of text values sent to a virtual pin — like a serial monitor in the cloud. Lines are timestamped and color-coded optionally. You can also type commands and send them to the device (bidirectional mode).
Default size: 3 × 3 grid cells
Configuration
| Property | Type | Default | Description |
|---|---|---|---|
maxLines | number | 100 | Maximum lines kept in view |
showTimestamp | boolean | true | Prepend each line with time |
| Device | device | — | The device to read/write |
| Pin | V0–V255 | — | The virtual pin for I/O |
| Label | string | — | Widget label |
Sending logs to the terminal
// Any string pushed to the pin appears as a new line
void loop() {
Vwire.run();
if (sensorError) {
Vwire.virtualSend(V10, "ERROR: sensor read failed");
}
float v = readVoltage();
char buf[64];
snprintf(buf, sizeof(buf), "Voltage: %.2f V", v);
Vwire.virtualSend(V10, buf);
delay(5000);
}
Bidirectional: receive commands from terminal
VWIRE_RECEIVE(V10) {
String cmd = param.asStr();
if (cmd == "reset") {
ESP.restart();
} else if (cmd.startsWith("setpin ")) {
int pin = cmd.substring(7).toInt();
digitalWrite(pin, HIGH);
Vwire.virtualSend(V10, "OK");
} else {
Vwire.virtualSend(V10, "Unknown command: " + cmd);
}
}
Log levels by convention
Since VWire sends raw strings, you can prefix lines to implement logging levels:
#define LOG_INFO(msg) Vwire.virtualSend(V10, "[INFO] " msg)
#define LOG_WARN(msg) Vwire.virtualSend(V10, "[WARN] " msg)
#define LOG_ERROR(msg) Vwire.virtualSend(V10, "[ERROR] " msg)
// Usage
LOG_INFO("Boot complete");
LOG_WARN("Low battery: 12%");
LOG_ERROR("Sensor timeout");