Timer Widget
The Timer widget displays elapsed or remaining time. It can count up from zero or count down to zero from a value supplied by the device. Commonly used for machine run-time, watering schedules, cycle counters, or process monitoring.
Default size: 2 × 2 grid cells
Configuration
| Property | Type | Default | Description |
|---|---|---|---|
mode | countdown | countup | countup | Timer direction |
format | mm:ss | hh:mm:ss | auto | auto | Time display format |
| Device | device | — | The device to read from |
| Pin | V0–V255 | — | The virtual pin (sends seconds) |
| Label | string | — | Widget label |
Pin value convention
The device sends the current timer value in seconds:
| Scenario | Value sent |
|---|---|
| Countup: 2 min 37 s elapsed | 157 |
| Countdown: 5 min remaining | 300 then decrements |
| Reset | 0 |
Firmware example: count-up (machine run time)
unsigned long startMs = 0;
bool running = false;
VWIRE_RECEIVE(V0) {
int cmd = param.asInt(); // 1=start, 0=stop/reset
if (cmd == 1) { startMs = millis(); running = true; }
else { running = false; }
}
void loop() {
Vwire.run();
if (running) {
unsigned long elapsed = (millis() - startMs) / 1000;
Vwire.virtualSend(V0, elapsed);
}
delay(1000);
}
Firmware example: countdown (irrigation timer)
int remaining = 0;
void startIrrigation(int seconds) {
remaining = seconds;
}
void loop() {
Vwire.run();
if (remaining > 0) {
remaining--;
Vwire.virtualSend(V0, remaining);
if (remaining == 0) {
stopValve();
Vwire.virtualSend(V0, 0);
}
}
delay(1000);
}
Tips
Push every second
For a smooth visual countdown/countup, push the value every 1000 ms on the device. The widget does not auto-tick — it always shows the last received value.