MQTT API Reference
This page describes the full MQTT topic namespace, authentication model, payload conventions, and QoS guidance for Vwire devices.
Two separate credentials
Vwire uses two distinct device credentials — each serves a different purpose:
| Credential | Where to find it | Purpose |
|---|---|---|
| Auth Token | Device detail page → Auth Token | MQTT password for authentication only |
| Device ID | Device detail page → Device ID (e.g. VW-ABC123) | Used in every MQTT topic for message routing |
The auth token proves who you are. The device ID identifies which MQTT topics belong to your device. Never use the auth token in topic paths — use the Device ID.
Connection details
| Field | Value |
|---|---|
| Broker | mqtt.vwire.io |
| Port (TLS) | 8883 (recommended) |
| Port (plain TCP) | 1883 |
| TLS | Required for port 8883 |
| Protocol | MQTT 3.1.1 |
Authentication fields
| Field | Value |
|---|---|
clientId | Any unique string — the library uses the Device ID |
username | Device ID (e.g. VW-ABC123) |
password | Auth Token (e.g. at_xxxxxxxxxxxxxxxx) |
Topic tree
vwire/
{deviceId}/ ← Device ID (VW-XXXXXX or VU-XXXXXX), NOT the auth token
pin/{pin} ← Device PUBLISHES sensor value (e.g. pin/V0)
cmd/{pin} ← Server PUBLISHES command to device (e.g. cmd/V1)
status ← Device PUBLISHES online/offline (LWT)
heartbeat ← Device PUBLISHES health info
sync/{pin} ← Device PUBLISHES sync request for a pin
notify ← Device PUBLISHES push notification
alarm ← Device PUBLISHES persistent alarm
alarm_ack ← Server PUBLISHES alarm acknowledgment back to device
email ← Device PUBLISHES email request
ack/{msgId} ← Device PUBLISHES reliable delivery acknowledgment
ota ← Server PUBLISHES OTA firmware command
ota_status ← Device PUBLISHES OTA progress/result
log ← Device PUBLISHES debug log message
Device → Server topics
Sensor / virtual pin value
vwire/{deviceId}/pin/{pin}
Published by the device when calling Vwire.virtualSend().
Payload — single value:
["23.5"]
Payload — multiple values (multi-param):
["val1", "val2", "val3"]
QoS: 0 for frequent sensor readings, 1 for important state changes
Device status (LWT)
vwire/{deviceId}/status
Online payload (published by device after connect):
{"status": "online"}
Offline payload (LWT — published by broker when device disconnects):
{"status": "offline"}
QoS: 1, Retain: true
Heartbeat
vwire/{deviceId}/heartbeat
Published periodically by the device. Updates lastSeenAt, IP address, and firmware version in the dashboard.
{
"uptime": 12345,
"heap": 32000,
"rssi": -65,
"ip": "192.168.1.100",
"fw": "3.1.0"
}
Push notification
vwire/{deviceId}/notify
Published when the device calls Vwire.notify(message). The server delivers this as a push notification and bell notification to the user.
Payload: raw UTF-8 string message (not JSON)
Temperature exceeded 85°C!
Persistent alarm
vwire/{deviceId}/alarm
Published when the device calls Vwire.alarm(). Delivers a persistent alarm to the mobile app requiring user acknowledgment.
{
"type": "alarm",
"message": "🚨 Critical: Pressure too high!",
"alarmId": "alarm_1234567890",
"sound": "alarm",
"priority": 3,
"timestamp": 1708000000000
}
Email notification
vwire/{deviceId}/email
Published when the device calls Vwire.email(subject, body). Requires a PRO plan or higher.
{
"subject": "Daily Status Report",
"body": "All sensors nominal at 09:00 AM."
}
Reliable delivery acknowledgment
vwire/{deviceId}/ack/{msgId}
Published by the device to acknowledge receipt of a reliable delivery command. The server removes the message from its retry queue.
Payload: "ok" or "error:<reason>"
OTA progress / result
vwire/{deviceId}/ota_status
Published by the device during an OTA update.
{"progress": 42}
{"result": "ok", "version": "1.3.0"}
{"result": "error", "reason": "invalid hash"}
Sync request
vwire/{deviceId}/sync/{pin}
Published by the device when calling Vwire.syncVirtual(V0). The server responds by publishing the last stored value for that pin on the command topic.
Debug log
vwire/{deviceId}/log
Published when the device calls Vwire.debug(). Raw UTF-8 string. Visible in server logs; not stored.
Server → Device topics
Command / write virtual pin
vwire/{deviceId}/cmd/{pin}
Published by the server when a dashboard widget sends a value to the device. The device receives this as a VWIRE_RECEIVE(Vn){} callback.
Payload — single value:
["1"]
Payload — multi-param:
["255", "128", "0"]
OTA firmware command
vwire/{deviceId}/ota
Published by the server when the user clicks "Upload & Deploy" in the dashboard.
{
"url": "https://app.vwire.io/api/v1/ota/firmware/uuid.bin",
"sha256": "abc123def456...",
"version": "1.3.0",
"size": 712432
}
Alarm acknowledgment
vwire/{deviceId}/alarm_ack
Published by the server when the user dismisses or snoozes an alarm in the app.
{
"alarmId": "alarm_1234567890",
"action": "stopped",
"snoozeMinutes": 0,
"timestamp": 1708000000000
}
Payload conventions
| Type | Example | MQTT payload |
|---|---|---|
| Integer | 42 | ["42"] |
| Float | 23.5 | ["23.5"] |
| String | "hello" | ["hello"] |
| GPS | lat/lng | ["48.858,2.294"] |
| Multi-param | R,G,B | ["255","128","0"] |
QoS reference
| Traffic type | QoS | Retain |
|---|---|---|
| Frequent sensor data | 0 | No |
| Important events | 1 | No |
| Control commands | 1 | No |
| Device status (LWT) | 1 | Yes |
| OTA commands | 1 | No |
| Alarms / notifications | 1 | No |
Connection details
| Field | Value |
|---|---|
| Broker | app.vwire.io |
| Port (TLS) | 8883 |
| Port (WebSocket TLS) | 443 |
| TLS requirement | Required |
| Authentication | Token as clientId, username, password |
| Protocol | MQTT 3.1.1 |
Topic tree
vwire/
{deviceToken}/
data/
v/{pin} ← device publishes sensor value
cmd/
v/{pin} ← server/dashboard publishes command
status ← device ONLINE/OFFLINE (LWT)
info ← device metadata
ota ← OTA update URL
sync ← pin sync on reconnect
Data topics (device → server)
Virtual pin value
vwire/{token}/data/v/{pin}
Payload:
["value"]
Multiple values (multi-param):
["val1", "val2", "val3"]
QoS: 0 (for frequent sensor readings) or 1 (for important events)
Device status
vwire/{token}/status
Online payload:
{"status": "online", "ip": "192.168.1.105", "ver": "1.2.3"}
Offline (LWT) payload:
{"status": "offline"}
QoS: 1, Retain: true
Device info
vwire/{token}/info
{
"firmware": "1.2.3",
"hardware": "ESP32",
"mac": "A4:CF:12:34:56:78"
}
Command topics (server → device)
Write virtual pin
vwire/{token}/cmd/v/{pin}
Payload:
["value"]
Device receives this as a VWIRE_RECEIVE(Vn) callback.
OTA update
vwire/{token}/ota
{
"url": "https://app.vwire.io/api/v1/ota/firmware/uuid.bin",
"sha256": "abc123...",
"version": "1.3.0",
"size": 712432
}
Sync pins
vwire/{token}/sync
{"pins": [0, 1, 5]}
Server sends this after a device reconnects; the device should call Vwire.syncVirtual() for listed pins.
Payload conventions
| Type | JavaScript | MQTT payload |
|---|---|---|
| Integer | 42 | ["42"] |
| Float | 23.5 | ["23.5"] |
| String | "hello" | ["hello"] |
| GPS | lat/lng pair | ["48.858,2.294"] |
| JSON object | {a:1} | ["{\"a\":1}"] (escaped) |
| Array | [1,2,3] | ["1","2","3"] |
QoS reference
| Traffic type | QoS | Retain |
|---|---|---|
| Frequent sensor data | 0 | No |
| Control commands | 1 | No |
| Device status | 1 | Yes |
| OTA messages | 1 | No |
| LWT | 1 | Yes |