Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
![]() Slide 1: Setting up and IoT | ||||||||
Line: 178 to 178 | ||||||||
The CayenneMessage class | ||||||||
Added: | ||||||||
> > | ![]() Analogue to Digital ConversionOften real world signals are analogue in nature. Before treating them digitally we must convert them to digital valuesThis is done by an Analogue to Digital Converter The ESP8266 has a 10 bit ADC on chip, the ESP32 has 3 12 bit ADCs To demonstrate this we use a photo resistor reading the light intensity. Photo resistor and LEDThe photo resistor and the 1 kΩ resistor form a voltage dividerThe LED can be switched on by program and changes the light Intensity seen by the photo resistor
ADC readout
Prototype board on Cayenne![]() The prototype GUI![]() History of Intensity Measurements![]() A trigger in CayenneWe will observe the light intensity a and switch a light on, if it gets too dark![]() The trigger code![]() | |||||||
A Qt app and Cayenne MQTT | ||||||||
Line: 244 to 291 | ||||||||
| ||||||||
Added: | ||||||||
> > |
|
Line: 1 to 1 | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() Slide 1: Setting up and IoT | |||||||||||||||
Line: 173 to 173 | |||||||||||||||
![]() | |||||||||||||||
Changed: | |||||||||||||||
< < | The callback gets a tuple with topic and payload as parameter The CayenneMessage class helps with parsing the message | ||||||||||||||
> > | The callback gets a tuple with topic and payload as parameter The CayenneMessage class helps with parsing the message The CayenneMessage class | ||||||||||||||
A Qt app and Cayenne MQTT | |||||||||||||||
Line: 234 to 237 | |||||||||||||||
| |||||||||||||||
Added: | |||||||||||||||
> > |
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
![]() Slide 1: Setting up and IoT | ||||||||
Line: 8 to 8 | ||||||||
The Cayenne MQTT protocolIn the last lecture we have seen the command message sent by Cayenne: | ||||||||
Changed: | ||||||||
< < |
![]() | |||||||
> > |
| |||||||
Trying the protocol with MQTTfx | ||||||||
Line: 103 to 102 | ||||||||
With this information we understand how the Cayenne MQTT client works:
| ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
| ||||||||
Added: | ||||||||
> > | Cayenne MQTT client publishWhen you publish measurement data with
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 typesA big number of data types is defined in the Cayenne MQTT protocolHave 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![]() Parsing the command message![]() The CayenneMessage class helps with parsing the message | |||||||
A Qt app and Cayenne MQTTThe graphical user interface of Cayenne is fairly limited.Can we write an application with another GUI system interacting | ||||||||
Line: 207 to 231 | ||||||||
| ||||||||
Added: | ||||||||
> > |
|
Line: 1 to 1 | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() Slide 1: Setting up and IoTSession 4: Sending real measurement data to Cayenne andreceiving commands and executing them on the hardwareUli Raichformally CERN, Geneva, Switzerland | |||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||
> > | The Cayenne MQTT protocolIn the last lecture we have seen the command message sent by Cayenne:![]() Trying the protocol with MQTTfxThe MQTTfx client allows you to
Starting MQTTfx![]() Setting up the profile![]() Copy Cayenne credentials![]() Connecting to CayenneOnce the profile is created you can connect to Cayenne with the “connect” button.You should see the “offline” note in on your Cayenne device page go away Once connected we can start sending messages to Cayenne Publish a message on CayenneCayenne MQTT expects topics of the following form:v1/username/things/clientID/data/channel This tells Cayenne that “data” are going to be sent. Replace “username” with your Cayenne user name and “clientID” with the client ID of your device We will send dummy temperature data to channel 0. Therefore “channel” must be replaced by “0”. The payloadThe payload (the actual data) has the following form:type,unit=value In our case: Type (temperature): temp Unit (Celsius): c Value: 29.3 (typical Ugandan temperature) Our payload therefore becomes: Temp,c=29.3 Publish the data message![]() MQTTfx data seen in Cayenne![]() Subscribing to cmd messagesIn order to see the command messages e.g. thosesent by the push button we must first subscribe to them. The format of a subscription is: v1/username/things/clientID/cmd/channel Since our push button is connected to channel 3 this is what we define as channel . v1/88253c70-76e9-11e9-9636-f9904f7b864b/things/ 1ce44ea0-76ea-11e9-b4eb-6bf2c2412b24/cmd/3 Subscribing in MQTTfx![]() Clicking the button![]() Cayenne is waiting for a response![]() Treating the commandNormally we would treat the command by acting on the hardware.If this was successful we would inform Cayenne that the new value was set: Format: v1/88253c70-76e9-11e9-9636-f9904f7b864b/things/ 1ce44ea0-76ea-11e9-b4eb-6bf2c2412b24/data/3 and the topic would be the new value: in this case: 1 Sending the response![]() The switch shows “on”![]() The Cayenne MQTT clientWith this information we understand how the Cayenne MQTT client works:
Measurement typesA big number of data types is defined in the Cayenne MQTT protocolHave a look at the docs under”Supported data types”: https://mydevices.com/cayenne/docs/cayenne-mqtt-api/#cayenne-mqtt-api-mqtt-messaging-topics ![]() Only the most basic ones are implemented in our client: ![]() Measurement unitsThe same is true for the units, here are the ones defined in the client:![]() Combining measurement and publishingIn session 2 we have seen how to readout sensors and control actuatorsNow 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)![]() SHT30 on Cayenne(2)![]() Cayenne MQTT client subscribeThis is a little more tricky:We have to create a callback function and register it with the Cayenne MQTT client When the push button or slider on Cayenne are activated this function will be called The function must find out from which channel the request is coming, and which are the data It must then act on the hardware correspondingly The Cayenne MQTT client sends a response message without our intervention A Qt app and Cayenne MQTTThe graphical user interface of Cayenne is fairly limited.Can we write an application with another GUI system interacting with our devices connected to the Cayenne MQTT broker? Example: The WeMos D1 buzzer. We want to play a song from a list of choices. The Buzzer GUI![]() The Cayenne MQTT C libraryThe Cayenne MQTT C library contains everything we need to communicate with the Cayenne MQTT broker:
The end of the showThere is still work for you during the exercises session to make you IoT node work with Sensor readoutPublishing the result on Cayenne (for the SHT30) Subscribe to a command message from the Cayenne slider to modify the settings of a colour component of your WS2812 rgb LED For further study please consult: https://afnog.iotworkshop.africa/do/view/AFNOG/AFNOGWorkshop2019 You will find plenty examples on https://github.com/uraich?tab=repositories ![]() | ||||||||||||||||||||||||||||||||
%SLIDESHOWEND%
-- ![]() | |||||||||||||||||||||||||||||||||
Line: 11 to 190 | |||||||||||||||||||||||||||||||||
Comments | |||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||
> > |
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Added: | ||||||||
> > |
![]() Slide 1: Setting up and IoTSession 4: Sending real measurement data to Cayenne andreceiving commands and executing them on the hardwareUli Raichformally CERN, Geneva, Switzerland--![]() Comments |