MQTT — Code Examples
Real-time, bidirectional examples that connect to the Virtuino Cloud MQTT broker — publishing sensor values up and subscribing to receive commands from a dashboard, live, with no polling.
All examples use PubSubClient by Nick O'Leary. For the full topic structure, broker settings and connection reference, see the MQTT Broker Setup guide.
This page is new and growing.
We're adding more MQTT code examples here regularly — for now, start with what's below.
Examples
Get Started with MQTT
Send a value to Virtuino Cloud over MQTT and switch your board's LED from the dashboard — the fastest way to see a full publish/subscribe loop working, in seven steps.
Open tutorial
ESP32 — Two-way Control
Button state published up, two LEDs controlled from dashboard switches. Full wiring, code and dashboard steps included.
Open tutorial
HTML tutorial
Publish + Subscribe to a Relay
ESP8266 / ESP32 — plain and secure (TLS) connections, with a unique client ID for every board.
Open guide
HTML tutorial
Command Confirmation
Get alerted when a command is not actually executed by the device. Full ready-to-flash sketch included on the page.
Open tutorial
HTML tutorial
Device Online / Offline Status
Know when a board drops off and why. Every connection appears in My Virtuino World on its own, and the device status widget alerts you — no extra code in the firmware.
Open guide
More examples — sensors, multi-device setups, Node-RED — coming soon.