|
META TOPICPARENT |
name="WorkshopSlides" |
Slide 1: Setting up and IoT |
| The Cayenne MQTT protocol
In the last lecture we have seen the command message sent by Cayenne: |
|
< < |
 |
> > |
At first glance the Cayenne message looks pretty unreadable but comparing it to the Cayenne credentials gives us some insight |
|
Trying the protocol with MQTTfx |
| With this information we understand how the Cayenne MQTT client works:
- In its begin method it gets the Cayenne credentials and saves them
- It sets up a root topic string
self.rootTopic = "v1/%s/things/%s" % (username, clientid)
|
|
< < |
-
- It connects to WiFi and then to the Cayenne MQTT
broker using the tcp protocol
|
> > |
-
- It connects to WiFi and then to the Cayenne MQTT
broker using the tcp protocol
|
|
-
- It subscribes to the cmd topic
|
|
> > | Cayenne MQTT client publish
When you publish measurement data with
- celsiusWrite(channel,value)
- humidityWrite(channel,value)
- hectrPascalWrite(channel,value)
- etc.
The root topic string is completed to a full data topic including the channel information
The corresponding data type and the unit (this information is hard coded into the call:
for celsiusWrite the data type is “temp” and the unit is “c”)
as well as the value as used to create the payload string This information is published |
| Measurement types
A big number of data types is defined in the Cayenne MQTT protocol Have a look at the docs under”Supported data types”: |
|
Combining measurement and publishing |
|
< < | In session 2 we have seen how to readout sensors and control actuators
Now we have seen how to publish and how to subscribe to Cayenne messages
We have to combine those two in order to create a full cayenne IoT node. |
> > | In session 2 we have seen how to readout sensors and control actuators
Now we have seen how to publish and how to subscribe to Cayenne messages
We have to combine those two in order to create a full cayenne IoT node. |
|
SHT30 on Cayenne(1) |
| without our intervention
|
|
> > | Registering the callback
Parsing the command message
The callback gets a tuple with topic and payload as parameter The CayenneMessage class helps with parsing the message
|
| A Qt app and Cayenne MQTT
The graphical user interface of Cayenne is fairly limited.
Can we write an application with another GUI system interacting |
|
META FILEATTACHMENT |
attachment="cayenneSHT30Publish1.png" attr="" comment="" date="1558685485" name="cayenneSHT30Publish1.png" path="cayenneSHT30Publish1.png" size="84002" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="CayenneSHT30Publish.png" attr="" comment="" date="1558685489" name="CayenneSHT30Publish.png" path="CayenneSHT30Publish.png" size="68945" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="QtBuzzer.png" attr="" comment="" date="1558685732" name="QtBuzzer.png" path="QtBuzzer.png" size="23313" user="UliRaich" version="1" |
|
|
> > |
META FILEATTACHMENT |
attachment="cayenneCredentialsCmp.png" attr="" comment="" date="1560010275" name="cayenneCredentialsCmp.png" path="cayenneCredentialsCmp.png" size="31312" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="cayenneCallback.png" attr="" comment="" date="1560010917" name="cayenneCallback.png" path="cayenneCallback.png" size="37886" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="cayenneRegCallback.png" attr="" comment="" date="1560010917" name="cayenneRegCallback.png" path="cayenneRegCallback.png" size="26847" user="UliRaich" version="1" |
|