The WeMos D1 mini has a built-in WiFi interface
In order to communicate with other IoT nodes we must therefore
connect to the WiFi network first
On top of WiFi we will run a TCP session
On top of TCP we will run the MQTT protocol
On top of MQTT we have dedicated topics and payloads imposed by Cayenne
MQTT (Message Queuing Telemetry Transport: a publish-subscribe based
message protocol running of top of TCP.
A processor can subscribe to messages of a certain “topic” and/or it can push its
results on a certain topic
Receiving commands is a bit more tricky! We must:
In order to control a LED through MQTT we now simply interpret the payload:
Sign up at
https://mydevices.com/cayenne/signup
You find the documentation at
https://mydevices.com/cayenne/docs/intro
Contains short introductory video clips, information of Cayenne on Raspberry Pi and Arduino but also how to use Cayenne on any device.
Pointers to the Cayenne MQTT Libraries and their API
The Cayenne credentials are integrated into the MQTT topic string
Value and units are integrated into the payload string
This falls under “bring your own thing” !
Having a look at the Arduino sketch you can see that it uses the
Arduino Cayenne C++ library.
Cayenne MQTT libraries are available in
The Python Cayenne Client library depends on the Eclipse Paho MQTT library
Micropython uses its own, stripped down “umqtt” (micro mqtt) library
such that the standard Cayenne Client does not work on Micropython
but …
The Python Cayenne Client is Open Source and can be adapted to umqtt, which is what I did for you.
The adapted Client library uses the same API as the original one,
which means that the example programs work unchanged.
When creating a Cayenne Client Class it
Cayenne keeps measurement values which can be plotted as a history plot
or downloaded for further evaluation
Now we want to send a dummy temperature and a dummy humidity value.
How do we distinguish?
They use different communication channels!
We have seen that we can send temperature with
Cayenne supplies only 2 control widgets:
We can define the range for the slider in the above case: 0..255
We must define a callback function, which is called
whenever the user of the Cayenne dashboard
changes a setting on the push button or slider
The callback takes a message parameter which is a tuple of
Please compare the command message with our credentials and try to find out
to which channel this command has been addressed. Can you find the values as well?
Remember: we defined the push button on channel 3 and the slider in channel 2!
More on how to interpret this message in the next session
I | Attachment | History | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|---|
![]() |
afnog19-ws-session3.odp | r1 | manage | 5245.0 K | 2019-05-15 - 19:13 | UliRaich | |
![]() |
callbackResult.png | r1 | manage | 142.7 K | 2019-05-22 - 12:31 | UliRaich | |
![]() |
cayenneArduinoInstall.png | r1 | manage | 128.4 K | 2019-05-22 - 16:32 | UliRaich | |
![]() |
cayenneArduinoSketch.png | r1 | manage | 191.2 K | 2019-05-22 - 16:35 | UliRaich | |
![]() |
cayenneCmdMsg.png | r1 | manage | 189.5 K | 2019-05-22 - 19:15 | UliRaich | |
![]() |
cayenneCmdMsg2.png | r1 | manage | 68.6 K | 2019-05-22 - 19:15 | UliRaich | |
![]() |
cayenneConnect.png | r1 | manage | 137.9 K | 2019-05-22 - 16:52 | UliRaich | |
![]() |
cayenneConnectCode.png | r1 | manage | 56.8 K | 2019-05-22 - 16:52 | UliRaich | |
![]() |
cayenneCredentials.png | r1 | manage | 109.7 K | 2019-05-22 - 16:36 | UliRaich | |
![]() |
cayenneCustonWidget.png | r1 | manage | 184.8 K | 2019-05-22 - 19:26 | UliRaich | |
![]() |
cayenneDashButton.png | r1 | manage | 156.5 K | 2019-05-22 - 19:03 | UliRaich | |
![]() |
cayenneDashSlider.png | r1 | manage | 139.6 K | 2019-05-22 - 19:03 | UliRaich | |
![]() |
cayenneDashboardTempHum.png | r1 | manage | 119.5 K | 2019-05-22 - 18:56 | UliRaich | |
![]() |
cayenneDoc.png | r1 | manage | 158.3 K | 2019-05-22 - 16:21 | UliRaich | |
![]() |
cayenneDummyButtton.png | r1 | manage | 211.0 K | 2019-05-22 - 19:04 | UliRaich | |
![]() |
cayenneDummySlider.png | r1 | manage | 178.5 K | 2019-05-22 - 19:04 | UliRaich | |
![]() |
cayenneDummyTemp.png | r1 | manage | 71.1 K | 2019-05-22 - 18:32 | UliRaich | |
![]() |
cayenneEmptyDashboard.png | r1 | manage | 150.2 K | 2019-05-22 - 16:52 | UliRaich | |
![]() |
cayenneFunctionality.png | r1 | manage | 135.7 K | 2019-05-22 - 16:09 | UliRaich | |
![]() |
cayenneGaugeRanges.png | r1 | manage | 155.2 K | 2019-05-22 - 18:48 | UliRaich | |
![]() |
cayenneHot.png | r1 | manage | 147.2 K | 2019-05-22 - 18:32 | UliRaich | |
![]() |
cayenneMQTTCalls.png | r1 | manage | 67.0 K | 2019-05-22 - 18:56 | UliRaich | |
![]() |
cayenneNetLayers.png | r1 | manage | 34.5 K | 2019-05-22 - 16:45 | UliRaich | |
![]() |
cayenneRPI.png | r1 | manage | 150.8 K | 2019-05-22 - 16:24 | UliRaich | |
![]() |
cayenneRegisterRPI.png | r1 | manage | 148.3 K | 2019-05-22 - 16:24 | UliRaich | |
![]() |
cayenneSignup.png | r1 | manage | 122.2 K | 2019-05-22 - 16:15 | UliRaich | |
![]() |
cayenneStart.png | r1 | manage | 146.3 K | 2019-05-22 - 16:15 | UliRaich | |
![]() |
cayenneTempGauge.png | r1 | manage | 205.1 K | 2019-05-22 - 18:41 | UliRaich | |
![]() |
cayenneTempHum.png | r1 | manage | 82.7 K | 2019-05-22 - 18:52 | UliRaich | |
![]() |
cayenneWarm.png | r1 | manage | 149.6 K | 2019-05-22 - 18:44 | UliRaich | |
![]() |
cayenne_RPI_ManualInstallation.png | r1 | manage | 189.9 K | 2019-05-22 - 16:30 | UliRaich | |
![]() |
changedCallback.png | r1 | manage | 15.3 K | 2019-05-22 - 16:06 | UliRaich | |
![]() |
dummyTemp.png | r1 | manage | 110.2 K | 2019-05-22 - 18:32 | UliRaich | |
![]() |
dummyTempFixed.png | r1 | manage | 126.3 K | 2019-05-22 - 18:32 | UliRaich | |
![]() |
dummyTempHistory.png | r1 | manage | 29.5 K | 2019-05-22 - 18:32 | UliRaich | |
![]() |
dummyTempPars.png | r1 | manage | 137.8 K | 2019-05-22 - 18:37 | UliRaich | |
![]() |
micropython-lib.png | r1 | manage | 75.2 K | 2019-05-14 - 17:31 | UliRaich | |
![]() |
mqttDemo.png | r1 | manage | 191.3 K | 2019-05-14 - 17:23 | UliRaich | |
![]() |
mqttDummySensorDemo.png | r1 | manage | 74.4 K | 2019-05-20 - 18:40 | UliRaich | |
![]() |
mqttExample.png | r2 r1 | manage | 73.2 K | 2019-05-15 - 16:12 | UliRaich | |
![]() |
mqttPostOfffice.png | r1 | manage | 50.2 K | 2019-05-14 - 17:18 | UliRaich | |
![]() |
ourCredentials.png | r1 | manage | 17.9 K | 2019-05-22 - 19:15 | UliRaich | |
![]() |
realData.png | r1 | manage | 27.7 K | 2019-05-15 - 17:12 | UliRaich | |
![]() |
subscribeDemo.png | r1 | manage | 78.3 K | 2019-05-20 - 18:45 | UliRaich | |
![]() |
umqttDemo.png | r2 r1 | manage | 72.2 K | 2019-05-14 - 17:38 | UliRaich | |
![]() |
wifiConnect.png | r1 | manage | 128.4 K | 2019-05-14 - 17:18 | UliRaich | |
![]() |
wifiDemoCode.png | r1 | manage | 43.8 K | 2019-05-15 - 16:14 | UliRaich |