Difference: Cayenne (2 vs. 3)

Revision 32019-05-28 - UliRaich

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

Connecting to Cayenne

A Micropython class connecting to WiFi and subscribing to the myDevices MQTT broker

Line: 9 to 9
  In order to connect to myDevices Cayenne you need:
  • your WiFi SSID
Changed:
<
<
  • your "WiFi password
>
>
  • your WiFi password
 
  • the Cayenne credentials:
    • client name
    • user name
    • password
Changed:
<
<
The CayenneMQTTClient class has a begin method taking Cayenne username, password and client id as parameters. The ssid and wifiPassword have default values but can be specified as well. The begin method will first connect to WiFi and then connect to the MQTT broker at mqtt.mydevices.com. It then subscribes to the command topic such that cmd messages from Cayenne can be passed on to a callback routine registered by the user of the CayenneMQTTClient class. In case of a cmd message the required response message is sent automatically.
>
>
The CayenneMQTTClient class has a begin method taking Cayenne username, password and client id as parameters. The ssid and wifiPassword have default values but can be specified as well. The begin method will first connect to WiFi and then connect to the MQTT broker at mqtt.mydevices.com. It then subscribes to the command topic such that cmd messages from Cayenne can be passed on to a callback routine registered by the user of the CayenneMQTTClient class. In case of a cmd message, the required response message is sent automatically.
 
Changed:
<
<
If the OLED display is connected the state of network connection will be shown.
>
>
If the OLED display is connected, the state of network connection will be shown.
  The CayenneMQTTClient provides the following methods to publish measurement results:
Line: 33 to 33
 
  • digitalWrite(channel,value), value must be 0 or 1

Parsing of command messages

Changed:
<
<
The callback function gets a message, a tuple consisting of the topic and the payload, as parameter. This message must be parsed to extract the channel number and the value. The CayenneMessage class helps with this. Create a CayenneMessage object cayenneMsg with topic and payload (message[0] and message[1]) as parameters.
>
>
The callback function gets a message, a tuple consisting of the topic and the payload, as parameter. This message must be parsed to extract the channel number and the value. The CayenneMessage class helps with this. Create a CayenneMessage object cayenneMsg with topic and payload (message[0] and message[1]) as corresponding parameters.
  cayenneMsg.channel will then contain the channel number on which the command must be executed, cayenneMsg.value contains the value.
 
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