Skip to content

Code examples for the PhD Course on Smart Environments

Notifications You must be signed in to change notification settings

ichatz/iotphd2020

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PhD Course on Smart Environmnets 2020

Code examples for the PhD Course on Smart Environments carried out at the Department of Computer, Control, and Management Engineering Antonio Ruberti (DIAG) of the Sapienza University of Rome.

The examples assume a virtual sensor that generates messages containing random values for temperature, voltage consumption, a boolean door sensor and a timestamp.

Connection parameters

In order to connect to the AWS IoT broker it is necessary to supply the following command line parameters to the MQTT client:

  • --endpoint Your AWS IoT custom endpoint, not including a port for exmple: --endpoint abcd123456wxyz-ats.iot.us-east-1.amazonaws.com

  • --cert The file path to your client certificate, in PEM format

  • --key The file path to your private key, in PEM format

  • --root-ca The file path to root certificate authority, in PEM format

  • --client-id The device ID registered in the AWS IoT with all the necessary connect/publish permissions

  • --topic The topic to publish messages to

MQTT client using AWS Python SDK

The first file implements a virtual sensor that connects using the native AWS IoT SDK for Python.

You can either install it using pip:

pip install AWSIoTPythonSDK

Another option is to compile it from sources:

git clone https://github.com/aws/aws-iot-device-sdk-python.git cd aws-iot-device-sdk-python python setup.py install

MQTT client using Eclipse PAHO library

The second file implements a virtual sensor that connects to the AWS IoT broker using the Eclipse Paho MQTT Client. Details on how to setup the TLS connection with the correct parameters so that the MQTT client can connect to AWS IoT are available in this AWS blog.

The latest stable version is available in the Python Package Index (PyPi) and can be installed using

pip install paho-mqtt

To obtain the full code, including examples and tests, you can clone the git repository:

git clone https://github.com/eclipse/paho.mqtt.python

Once you have the code, it can be installed from your repository as well:

cd paho.mqtt.python python setup.py install

About

Code examples for the PhD Course on Smart Environments

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages