Connecting to Cayenne

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

Since every sensor node needs to first connect to WiFi and later subscribe to the MQTT broker at mqtt.mydevices.com I wrote a small micro Python class accomplishing these tasks. You will have to modify the code inserting:

  • your WiFi SSID
  • your "WiFi password
  • the Cayenne credentials:
    • client name
    • user name
    • password
After that you import cayenne and create a Cayenne class. This will set up your Wifi connection. After that you call cayenne.myttConnect() to connect to the myDevices MQTT broker. Once the connection is established you can call cayenne.publish(channel,dataString) to send your measurement data. The source code for the Cayenne class and an example showing how this is used with a DS18B20 temperature sensor is attached to this page.

https://afnog.iotworkshop.africa/pub/AFNOG/Cayenne/cayennePublic.py.txt

Please rename this file to cayenne.py after download

https://afnog.iotworkshop.africa/pub/AFNOG/Cayenne/cayenneDS18B20.py.txt

Please rename this file to cayenneDS18B20.py after download

-- Uli Raich - 2019-03-28

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt cayenneDS18B20.py.txt r1 manage 1.0 K 2019-03-28 - 12:42 UliRaich  
Texttxt cayennePublic.py.txt r1 manage 2.7 K 2019-03-28 - 12:42 UliRaich  
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2019-03-28 - UliRaich
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback