Intro: Getting Started With AWS IOT
What Is AWS IoT?
AWS IoT provides secure, bi-directional communication between Internet-connected things (such as sensors, actuators, embedded devices, or smart appliances) and the AWS cloud. This enables you to collect telemetry data from multiple devices and store and analyze the data. You can also create applications that enable your users to control these devices from their phones or tablets.
In this tutorial you will see how to connect things to AWS IOT, create rules, and receive data in your email and phone.
Step 1: Connect Things
Log in amazon web services platform and go to Internet of Things session. In there choose AWS IOT and click on it.
In AWS IOT dashboard click connect in this left tab, and configure device (GET STARTED).
Next click on Linux and Python, download the files and put it in a folder. Go to this directory in command line and type:
- $ chmod +x start.sh
- $ ./start.sh
This will install all python libraries in your board and run basicPubSub example to test communication.
If all goes well your board is connected to AWS IOT.
Step 2: Create a Rule
Click on Rules and create.
Put a name that you want to the rule, and a short description.
In SQL version, you can choose 2015-10-08 option. In attribute put * to get the entire message, and in Topic type sdk/test/Python, to follow the example. Condition keep blank.
Let add an action now!
Click on add action and choose SNS and configure the action.
Create a new SNS resource, click on Create a new resource button.
Create a new Topic, give it a name and a short description, now click on the topic and choose subscribe to topic.
Next, in Protocol option, choose email and put your email on it.
Now in role create a new role and allow it to get permission to send a message to the selected resource, click on Update Role button.
Click on Add action button.
Step 3: Run the Code
Now you are able to run the code and see the message coming from the board in your email.
In command line type:
- $ python aws-iot-device-sdk-python/samples/basicPubSub/basicPubSub.py -e a2sgybl1nt1z60.iot.us-west-2.amazonaws.com -r root-CA.crt -c DragonBoard.cert.pem -k DragonBoard.private.key
In my command the certificate files starts with DragonBoard because I named my thing as "DragonBoard", in your case will be other name and the endpoint number will be other. You can get your command by open start.sh file in notepad in the last line!
If you dont want to receive a lot of email of an example code, delete the while True: and run the code a once.
The message comming from the mqtt topic sdk/test/Python is sent to your email.
Now connect sensors and actuators to your board, create new rules, send notifications and create new projects!