Difference: PublishAndSubscribe (2 vs. 3)

Revision 32019-06-08 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WorkshopSlides"

Start Presentation

Slide 1: Setting up and IoT

Line: 8 to 8
 

The Cayenne MQTT protocol

In the last lecture we have seen the command message sent by Cayenne:

Changed:
<
<
cayenneCmdMsg2.png
>
>
cayenneCmdMsg2.png cayenneCredentialsCmp.png
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

Line: 103 to 102
 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)

Changed:
<
<
    • 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

Added:
>
>

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”:

Line: 126 to 138
 

Combining measurement and publishing

Changed:
<
<
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)

Line: 152 to 164
 without our intervention

Added:
>
>

Registering the callback

cayenneRegCallback.png

Parsing the command message

cayenneCallback.png

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

Line: 207 to 231
 
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"
Added:
>
>
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"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback