char deviceID[] ="PASTE_DEVICE_ID_HERE";char deviceToken[] ="PASTE_DEVICE_TOKEN_HERE";char host[] ="_IP_";int port =1883;
Data Structure
Qubitro currently has support for key-value paired JSON objects as a data type. Nested values are not supported yet.
{"Key1" : "Value1","Key2" : true,"Key3" : 90...}
An example : "{\"Temp\":33}"
Setup method
Set client id for identification
Set device id and token for authentication
Connect to the Qubitro broker
Subscribe to the topic
Set onMessage method to listen subscribed topic
voidsetup() {mqttClient.setId(deviceID);mqttClient.setDeviceIdToken(deviceID, deviceToken);Serial.println("Connecting to Qubitro...");if (!mqttClient.connect(host, port)) {Serial.println("Connection failed! Error code = ");Serial.println(mqttClient.connectError());Serial.println("Visit docs.qubitro.com or create a new issue on github.com/qubitro");while (1); }Serial.println("Connected to the Qubitro !");mqttClient.subscribe(deviceID);mqttClient.onMessage(receivedMessage); }
Subscribes to the topic (the device itself in this example)
Publishes data in a loop with a delay of 2 seconds.
Prints message and subscribed topic (the device itself in this example)
Example output:
Connecting to WiFi...Connected to the WiFiConnecting to Qubitro...Connected to the Qubitro !New message received:{"Temp":33}New message received:{"Temp":33}New message received:{"Temp":33}
Support and Feedback
If you have further questions or suggestions, feel free to join -> Qubitro Community Discord via this invitation link.