Skip to main content

Virtual Pins Reference

Virtual pins (V0V255) are the data channels between your firmware and your dashboard widgets.


Sending data to the dashboard

Call virtualSend inside your loop() at whatever interval makes sense for your sensor:

// Send a float
Vwire.virtualSend(V0, temperature);

// Send an integer
Vwire.virtualSend(V1, humidity);

// Send a formatted string
Vwire.virtualSend(V2, String(speed, 1) + " km/h");

// Send multiple values (CSV) — used by MAP widget
Vwire.virtualSend(V3, String(lat, 6) + "," + String(lon, 6));
Rate limiting

VWire will throttle extreme write rates. Sending data every 100–2000 ms is appropriate for most sensors.


Receiving commands from the dashboard

Register a handler for pins that widgets write back to (e.g. a Button or Switch):

VWIRE_RECEIVE(V5) {
int value = param.asInt();
digitalWrite(RELAY_PIN, value); // 1 = on, 0 = off
Vwire.virtualSend(V5, value); // echo back current state
}

VWIRE_RECEIVE(V6) {
int brightness = param.asInt();
analogWrite(LED_PIN, brightness); // 0–255 from a Slider
}

Reading pin state on connect

To restore state after a device reboots, sync the current server-side value in setup():

void setup() {
Vwire.begin(SSID, PASSWORD);

// Request current value from server
Vwire.syncVirtual(V5); // will trigger VWIRE_RECEIVE(V5) with current value
}

Data types

All values travel as strings over MQTT. The library provides helpers:

MethodReturns
param.asStr()const char*
param.asInt()int
param.asFloat()float
param.asDouble()double

Pin assignment tips

RangeSuggested use
V0V9Primary sensor readings
V10V19Secondary / computed values
V20V29Control outputs (relays, PWM)
V100V109GPS / location data
V200V255Metadata (heap, RSSI, IP, etc.)