This manual will guide you through the installation process of the AWS CLI, Mosquitto MQTT, and Python 3.x for the IoT Garden Project. These tools are essential for building and deploying IoT projects on the AWS platform and communicating with MQTT brokers.
Before proceeding with the installation process, make sure that you have the following prerequisites:
- Debian operating system
- Internet connection
-
Open the terminal and run the following command to install AWS CLI:
sudo apt-get update && sudo apt-get install awscli
-
Once the installation is complete, run the following command to check the version of AWS CLI:
aws --version
You should see the version of AWS CLI that you have installed.
-
Configure AWS CLI to use your AWS account
The following setup describes how to create a new IoT device in AWS cloud that will serve as the entry point for MQTT data published on the Fog network (local --> cloud).
-
Create an IoT device that will serve as the host for MQTT data The device is named bridge because it is resposible for receiving the data our local MQTT broker publishes.
aws iot create-thing --thing-name bridge
-
Now we need a method of connecting our local broker to the MQTT broker in AWS cloud. To connect to the broker there are 3 authentication requirements:
- A certificate associated with the thing "bridge" we created earlier
- Private key
- AWS root CA certificate
Run the following commands to download these objects into the ./authentication directory:
cd ./authentication
aws iot create-keys-and-certificate --set-as-active --certificate-pem-outfile certificate.pem.crt --private-key-outfile private.pem.key
wget -O root.ca.pem https://www.amazontrust.com/repository/AmazonRootCA1.pem
aws iot attach-thing-principal --thing-name bridge --principal <CERTIFICATE_ARN>
-
Open the terminal and run the following command to install Mosquitto MQTT:
sudo apt-get update && sudo apt-get install mosquitto mosquitto-clients
-
Once the installation is complete, run the following command to stop the Mosquitto MQTT broker service (we wish to run Mosquitto broker as a program):
sudo systemctl stop mosquitto && sudo systemctl disable mosquitto
-
Now you need to edit the mosquitto.conf file provided by the repo by replacing the following with the path to your authentication objects
bridge_cafile yourpath bridge_certfile yourpath bridge_keyfile yourpath
-
Get your AWS IoT endpoint domain
aws iot describe-endpoint --endpoint-type iot:Data-ATS
-
Edit the mosquitto.conf file by changing the endpoint paramater, replacing it with your own.
-
Open the terminal and run the following command to install Python 3.x:
sudo apt-get update && sudo apt-get install python3
-
Once the installation is complete, run the following command to check the version of Python 3.x:
python3 --version
You should see the version of Python 3.x that you have installed.
- Install pip packages
pip install -r requirements.txt
- Launch Mosquitto broker
mosquitto -c mosquitto.conf -v
- Launch the web API
python "./api/server.py"
- Launch the fog server master node
python "./api/rpi_master_humidity"