MQTT syntax

@shovelheadman I think the post that might be of more interest to you is this one: Data types for Cayenne MQTT API

Specifically, using the chart in that thread, I can add a digital input via MQTT like the following:

virtualWrite(5, 1, "digital_sensor", "d")

That passes digital value 1 on MQTT channel 5 to a 2-state sensor. Please note that the MQTT channel doesn’t have to match the GPIO pin, just being a virtual construct that can be used to populate Cayenne widgets with data. Many users keep it that way for the sake of code simplicity. The ‘1’ in this case is just my publishing a raw integer value, but this could of course be replaced with a variable that contains the 0/1 data you’re interested in publishing to Cayenne and tracking via this widget.

1 Like