Skip to main content

MQTT Protocol Reference

VWire uses MQTT 3.1.1 for device connectivity. This page covers the broker details, authentication model, topic schema, payload format, and special topics used by advanced integrations.


Broker endpoints

FieldValue
Hostmqtt.vwire.io
Port (TLS)8883
Port (plain TCP)1883
TLSRecommended and expected for production
ProtocolMQTT 3.1.1

Authentication

Every VWire device has two credentials:

CredentialMQTT fieldPurpose
Auth TokenpasswordAuthenticates the connection
Device IDclientId and usernameIdentifies the device and names its topics

The Arduino and Python libraries handle this automatically when you call Vwire.config(AUTH_TOKEN) and Vwire.setDeviceId(DEVICE_ID).


Topic schema

All topics use the Device ID in the topic path.

Device → Server

TopicPurpose
vwire/{deviceId}/pin/{pin}Publish a pin value such as V0, D2, or A0
vwire/{deviceId}/statusOnline/offline status (including LWT)
vwire/{deviceId}/heartbeatUptime, heap, RSSI, IP, firmware, and other health data
vwire/{deviceId}/sync/{pin}Request the last stored value for one pin
vwire/{deviceId}/syncRequest sync for all stored pin values
vwire/{deviceId}/notifySend a standard notification
vwire/{deviceId}/alarmSend a persistent alarm
vwire/{deviceId}/emailSend an email notification
vwire/{deviceId}/ack/{msgId}Reliable-delivery acknowledgment
vwire/{deviceId}/ota_statusOTA progress or result
vwire/{deviceId}/logDebug log message

Server → Device

TopicPurpose
vwire/{deviceId}/cmd/{pin}Write a value to a virtual, digital, or analog pin
vwire/{deviceId}/pinconfigSend GPIO configuration to the Arduino GPIO Pin Manager
vwire/{deviceId}/otaStart an OTA firmware update
vwire/{deviceId}/alarm_ackForward the user's alarm stop/snooze action

Payload format

Payload size limits

Each pin type has a maximum value size (UTF-8 bytes). Messages that exceed the limit are silently dropped by the server.

Pin typeMax payload
Virtual (V0V255)1 024 bytes
Digital (D0D99)16 bytes
Analog (A0A15)16 bytes

The broker also enforces a 64 KB maximum MQTT packet size (topic + headers + payload). See Pins & Data Limits for full details.

Pin values

Pin values are wrapped in a JSON array.

["value"]

For multiple values at once:

["value1", "value2", "value3"]

Examples:

["23.5"]
["255"]
["48.858844,2.294351"]
["255","128","0"]

If you use the Arduino or Python library, the JSON wrapping is handled automatically. Raw MQTT clients must wrap values themselves.

Alarm payload

Custom clients sending alarms should publish JSON like this:

{
"type": "alarm",
"message": "Pump failure",
"sound": "urgent",
"priority": 3,
"volume": 90,
"timestamp": 1740000000000
}
FieldRequiredNotes
typeYesMust be "alarm"
messageYesAlarm text shown to the user
soundNodefault, warning, or urgent
priorityNo1, 2, or 3
volumeNo0-100, defaults to 50
timestampNoUnix timestamp in milliseconds

Alarm acknowledgment payload

Custom MQTT clients that subscribe to vwire/{deviceId}/alarm_ack receive JSON like this when the user acts on an alarm:

{
"alarmId": "alarm_1740000000000",
"action": "snoozed",
"snoozeMinutes": 5,
"timestamp": 1740000123456
}

QoS levels

Message typeQoSRationale
Sensor data0Best-effort; occasional loss is acceptable
Commands1At-least-once delivery
OTA trigger1Must not be lost
LWT1Must be delivered on disconnect

Last Will Testament

The libraries configure LWT automatically during Vwire.begin():

FieldValue
LWT Topicvwire/{deviceId}/status
LWT Payload{"status":"offline"}
QoS1
Retaintrue

Keep-alive

The default keep-alive is 60 seconds.

  • After roughly 30 seconds without traffic, the client sends a PINGREQ.
  • If the broker receives no traffic for the keep-alive window, it considers the client disconnected and publishes the LWT.

Example raw MQTT session

# Publish temperature on V0
mosquitto_pub \
-h mqtt.vwire.io -p 8883 \
--cafile /etc/ssl/certs/ca-certificates.crt \
-i "VW-ABC123" \
-u "VW-ABC123" \
-P "at_your-auth-token" \
-t "vwire/VW-ABC123/pin/V0" \
-m '["23.5"]'
# Subscribe to commands on V1
mosquitto_sub \
-h mqtt.vwire.io -p 8883 \
--cafile /etc/ssl/certs/ca-certificates.crt \
-i "VW-ABC123" \
-u "VW-ABC123" \
-P "at_your-auth-token" \
-t "vwire/VW-ABC123/cmd/V1"
# Subscribe to alarm acknowledgments in a custom client
mosquitto_sub \
-h mqtt.vwire.io -p 8883 \
--cafile /etc/ssl/certs/ca-certificates.crt \
-i "VW-ABC123-listener" \
-u "VW-ABC123" \
-P "at_your-auth-token" \
-t "vwire/VW-ABC123/alarm_ack"