Difference: CommunicatingOverMQTT (1 vs. 5)

Revision 52019-06-16 - UliRaich

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

Communicating over MQTT

Line: 33 to 33
  https://afnog.iotworkshop.africa/pub/AFNOG/CommunicatingOverMQTT/clientPublic.py.txt
Added:
>
>
As you can observe by studying the begin method of the CayenneMQTTClient class that default values for ssid and wifiPassword are used, which correspond to the WiFi ssid and password we had during the tutorial in the classroom. In the Cayenne example programs the begin method is called without these parameters. If you want to run these programs with your own WiFi network, you will have to pass these two parameters ssid="Your SSID" and wifiPassword="Your WiFi password" thus overriding the default.

The method call will therefore be changed from:

client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID, loglevel=logging.INFO) to

client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID, ssid="Your SSID", wifPassword="Your Wifi paddword", loglevel=logging.INFO)

 https://afnog.iotworkshop.africa/pub/AFNOG/CommunicatingOverMQTT/__init__.py.txt

https://afnog.iotworkshop.africa/pub/AFNOG/CommunicatingOverMQTT/ledControlPublic.py.txt

Revision 42019-05-28 - UliRaich

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

Communicating over MQTT

Line: 6 to 6
 
Changed:
<
<
Below we see an example running the MQTT broker mosquitto, 2 nodes (mosquitto_sub) have subscribed to the topic AFNOG19 and AFNOG18 respectively.. When a third node publishes information on topic AFNOG19, then the first subscriber receives the information (payload) while when publishing on AFNOG18 it is the second subscriber seeing the message.
>
>
Below we see an example running the MQTT broker mosquitto. Two nodes (mosquitto_sub) have subscribed to the topic AFNOG19 and AFNOG18 respectively.. When a third node publishes information on topic AFNOG19, then the first subscriber receives the information (payload) while when publishing on AFNOG18 it is the second subscriber seeing the message.
  mqttDemo.png

MQTT and Cayenne

Line: 27 to 27
  Libraries in C, C++, Python, Java can be found on github.
Changed:
<
<
Unfortunately the Cayenne MQTT Python library depends on the Eclipse Paho MQTT Python client, which is not available on Micropython. I therefore ported the Cayenne MQTT Client class to the simple.py MQTT client available in Micropython. The API is the same and the example programs should work without modification.
>
>
Unfortunately, the Cayenne MQTT Python library depends on the Eclipse Paho MQTT Python client, which is not available on Micropython. I therefore ported the Cayenne MQTT Client class to the simple.py MQTT client available in micropython. The API is the same and the example programs should work without modification.
 
Changed:
<
<
The new Cayenne client package has already been integrated into Micropython such that you can make use of its classes and methods without any further installation.The source code has nevertheless been attached to this page for your inspection. Please remove the .txt extension after download to run the programs.
>
>
The new Cayenne client package has already been integrated into micropython such that you can make use of its classes and methods without any further installation.The source code has nevertheless been attached to this page for your inspection. Please remove the .txt extension after download to run the programs.
  https://afnog.iotworkshop.africa/pub/AFNOG/CommunicatingOverMQTT/clientPublic.py.txt
Line: 37 to 37
  https://afnog.iotworkshop.africa/pub/AFNOG/CommunicatingOverMQTT/ledControlPublic.py.txt
Changed:
<
<
In order to use the package clientPublic.py.txt must be renamed to client.py and the Cayenne and WiFi credentials must be added. This program together with __init__.py must be stored in a directory called "cayenne".
>
>
In order to use the package clientPublic.py.txt, it must be renamed to client.py and the Cayenne and WiFi credentials must be added. This program together with __init__.py must be stored in a directory called "cayenne".
 

The example program

Changed:
<
<
The example program uses hardware prepared for a simplistic demonstration IoT. It consists of a photo resistor in series with a 1kOhm resistor forming a voltage divider. The voltage over the photo resistor, changing with changing light intensity, is measured with the 10 bit ADC available on the ESP8266 and accessible on the A0 pin of the WeMos D1 mini CPU card. The measured voltage is published on channel 1. In addition to the photo resistor we have an LED shining on the photo resistor. This LED is connected to D0 on the WeMos D1 mini corresponding to GPIO 16 and can be controlled on channel 2. Finally the built-in LED on the CPU card, connected to D4 or GPIO 2 can be controlled through channel 3.
>
>
The example program uses hardware prepared for a simplistic demonstration IoT. It consists of a photo-resistor in series with a 1kOhm resistor forming a voltage divider. The voltage over the photo-resistor, changing with changing light intensity, is measured with the 10 bit ADC available on the ESP8266 and accessible on the A0 pin of the WeMos D1 mini CPU card. The measured voltage is published on channel 1. In addition to the photo-resistor we have an LED shining on the photo-resistor. This LED is connected to D0 on the WeMos D1 mini corresponding to GPIO 16 and can be controlled on channel 2. Finally the built-in LED on the CPU card, connected to D4 or GPIO 2 can be controlled through channel 3.
  proto.png

Revision 32019-04-25 - UliRaich

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

Communicating over MQTT

Changed:
<
<
MQTT, the Message Queuing Telemetry Transport protocol is the communication protocol of choice in many IoT applications. It uses a broker receiving subscriptions and publications, distributing messages on a certain topic to everybody subscribed to to it. It is a light weight protocol running of top of TCP.
>
>
MQTT, the Message Queuing Telemetry Transport protocol is the communication protocol of choice in many IoT applications. It uses a broker receiving subscriptions and publications, distributing messages on a certain topic to everybody subscribed to it. It is a light weight protocol running of top of TCP.
 
Changed:
<
<
Below we see an example running mosquitto, the MQTT broker, 2 nodes (mosquitto_sub) have subscribed to the topic AFNOG19 and AFNOG18 respectively.. When a third node publishes information on the topic AFNOG19, then the first subscriber receives the information while when publishing on AFNOG18 it is the second subscriber seeing the message.
>
>
Below we see an example running the MQTT broker mosquitto, 2 nodes (mosquitto_sub) have subscribed to the topic AFNOG19 and AFNOG18 respectively.. When a third node publishes information on topic AFNOG19, then the first subscriber receives the information (payload) while when publishing on AFNOG18 it is the second subscriber seeing the message.
  mqttDemo.png

MQTT and Cayenne

Changed:
<
<
Cayenne supplies an mqtt broker at mqtt.mydevices.com which uses a strict format for the topic and the payload string. When registering at MyDevices Cayenne as a new user you will be attributed a username and a password. For each device you register you will get a device_id.
>
>
Cayenne supplies an mqtt broker at mqtt.mydevices.com which uses a strict format for the topic and the payload string. When registering at MyDevices Cayenne as a new user you will be attributed a username and a password. For each device you register you will get a device_id.

cayenneCredentials.png

Cayenne uses these credentials in the MQTT topic to verify permission to access the MQTT broker. A typical publication topic has the form:

v1/username/things/clientID/data/channel

while the payload has the form:

type, unit=value (e.g. temp,c=24.5 to publish a temperature reading of 24.5 °C)

For the full details please refer to the Cayenne MQTT API.

Libraries in C, C++, Python, Java can be found on github.

Unfortunately the Cayenne MQTT Python library depends on the Eclipse Paho MQTT Python client, which is not available on Micropython. I therefore ported the Cayenne MQTT Client class to the simple.py MQTT client available in Micropython. The API is the same and the example programs should work without modification.

The new Cayenne client package has already been integrated into Micropython such that you can make use of its classes and methods without any further installation.The source code has nevertheless been attached to this page for your inspection. Please remove the .txt extension after download to run the programs.

https://afnog.iotworkshop.africa/pub/AFNOG/CommunicatingOverMQTT/clientPublic.py.txt

https://afnog.iotworkshop.africa/pub/AFNOG/CommunicatingOverMQTT/__init__.py.txt

https://afnog.iotworkshop.africa/pub/AFNOG/CommunicatingOverMQTT/ledControlPublic.py.txt

In order to use the package clientPublic.py.txt must be renamed to client.py and the Cayenne and WiFi credentials must be added. This program together with __init__.py must be stored in a directory called "cayenne".

The example program

The example program uses hardware prepared for a simplistic demonstration IoT. It consists of a photo resistor in series with a 1kOhm resistor forming a voltage divider. The voltage over the photo resistor, changing with changing light intensity, is measured with the 10 bit ADC available on the ESP8266 and accessible on the A0 pin of the WeMos D1 mini CPU card. The measured voltage is published on channel 1. In addition to the photo resistor we have an LED shining on the photo resistor. This LED is connected to D0 on the WeMos D1 mini corresponding to GPIO 16 and can be controlled on channel 2. Finally the built-in LED on the CPU card, connected to D4 or GPIO 2 can be controlled through channel 3.

proto.png

  -- Uli Raich - 2019-04-09
Line: 20 to 51
 
<--/commentPlugin-->

META FILEATTACHMENT attachment="mqttDemo.png" attr="" comment="" date="1556209983" name="mqttDemo.png" path="mqttDemo.png" size="195883" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="cayenneCredentials.png" attr="" comment="" date="1556216632" name="cayenneCredentials.png" path="cayenneCredentials.png" size="147553" user="UliRaich" version="1"
META FILEATTACHMENT attachment="__init__.py.txt" attr="" comment="" date="1556217545" name="__init__.py.txt" path="__init__.py.txt" size="22" user="UliRaich" version="1"
META FILEATTACHMENT attachment="ledControlPublic.py.txt" attr="" comment="" date="1556218597" name="ledControlPublic.py.txt" path="ledControlPublic.py.txt" size="2206" user="UliRaich" version="1"
META FILEATTACHMENT attachment="clientPublic.py.txt" attr="" comment="" date="1556219501" name="clientPublic.py.txt" path="clientPublic.py.txt" size="12022" user="UliRaich" version="1"
META FILEATTACHMENT attachment="proto.png" attr="" comment="" date="1556220015" name="proto.png" path="proto.png" size="904008" user="UliRaich" version="1"

Revision 22019-04-25 - UliRaich

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

Communicating over MQTT

Changed:
<
<
Article text.
>
>
MQTT, the Message Queuing Telemetry Transport protocol is the communication protocol of choice in many IoT applications. It uses a broker receiving subscriptions and publications, distributing messages on a certain topic to everybody subscribed to to it. It is a light weight protocol running of top of TCP.

Below we see an example running mosquitto, the MQTT broker, 2 nodes (mosquitto_sub) have subscribed to the topic AFNOG19 and AFNOG18 respectively.. When a third node publishes information on the topic AFNOG19, then the first subscriber receives the information while when publishing on AFNOG18 it is the second subscriber seeing the message.

mqttDemo.png

MQTT and Cayenne

Cayenne supplies an mqtt broker at mqtt.mydevices.com which uses a strict format for the topic and the payload string. When registering at MyDevices Cayenne as a new user you will be attributed a username and a password. For each device you register you will get a device_id.

  -- Uli Raich - 2019-04-09

Comments

<--/commentPlugin-->
\ No newline at end of file
Added:
>
>
META FILEATTACHMENT attachment="mqttDemo.png" attr="" comment="" date="1556209983" name="mqttDemo.png" path="mqttDemo.png" size="195883" user="UliRaich" version="1"

Revision 12019-04-09 - UliRaich

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

Communicating over MQTT

Article text.

-- Uli Raich - 2019-04-09

Comments

<--/commentPlugin-->
 
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