Software apps and online services
A project done by students of Singapore Polytechnic.
1) Connect your breadboard as shown above. Combine 1 and 2 ( Deadline reached before finishing fritzing diagram)
Detect rain is step 1.5,viewing light data on AWS is the rest of the steps
1.5) To view rain, run rainbutton.py.
2) Make sure you have an AWS Educate account and login. If you don't have one create a new one.
3) You should arrive at this page after clicking on "AWS account".
4) Click on AWS Console and search for IoT Core.
5) Create a thing in IOT Core.
6) Create a certificate for your thing. Then choose “One-click certificate creation”.
7) Download the 3 links given.
8) Go to https://docs.aws.amazon.com/iot/latest/developerguide/server-authentication.html#server-authentication-certs right-click on the Amazon Root CA 1 and select Save as.
9) Create a folder and store the 4 files there. Rename the files as above to make the names more friendly. Then click on the activate button on the site.
10) Register a thing on the next page.
11) On the IoT Core Dashboard, select policy and then press Create new policy.
12) Enter "MyRaspberryPiSecurityPolicy" as Name, "iot:*" as Action, * as Resource ARN and check the allow box. Then click on the Create button.
13) Click on the Security certificates. Check the certificates box and then click on attach policy under the Action button. Check the policy created earlier and then click on Attach.
14) Click on Attach thing and then check on the thing you created.
15) Click on Manage ----> Things and then choose Interact. You should be seeing your REST API endpoint. Copy it and save it into your Notepad.
16) Now go to your Raspberry pi and run these 3 commands
sudo pip install --upgrade --force-reinstall pip==9.0.3
sudo pip install AWSIoTPythonSDK --upgrade --disable-pip-version-check
sudo pip install --upgrade pip
sudo pip install paho-mqtt
17) Enter the codes for aws_pubsub.py and save it. Remember to change "YourEndpoint" in host = "YourEndPoint.amazonaws.com" to the REST API endpoint you saved in step 15. Also, rename basicPubSub to a unique identifier in 'rename my_rpi = AWSIoTMQTTClient("basicPubSub")'
18) Place the 4 certificates you downloaded into the same folder as your aws_pubsub.py.
19.1) Go to IAM service within the roles settings in the AWS console.
19.2) Select Roles, click on Create Role, AWS service then on IOT.
19.3) Select IoT under select your use case.
19.4) Click next until you reach the reviews page.
19.5) Enter a role name.
20.1) Go to Amazon DynamoDB dashboard and click on Create Table.
20.2) Create the table as shown above.
21) Now go back to the AWS IoT console choose Create a rule which is located within Act.
22) Write down the following as shown above.
SELECT * FROM 'sensors/light'
under the Rule Query Statement.
24) Select Add action in set one or more actions.
25) Select the option above.
26) On the configure action page, choose the table created earlier.
27) Under *IAM role name, select your previously created role name in step 19.5.
28) Click on create on the bottom right and then click Create Rule.
30) Run the aws_pubsub.py using sudo python aws_pubsub.py in the correct directory in your raspberry pi console.
31) Run python server.py in your console without the sudo.
32) Open http://<ipaddressofyourRPI:5000 replace <ipaddressofyourRPI> with your raspberry pi ip address and you should be able to see the graph.
33) Go to https://ap-southeast-1.console.aws.amazon.com/sns/v2 and select Get Started.
34) Choose topics and select create new topics.
35) Enter any topic name and detail name, then click on Create topic. Take note of the ARN.
36) In the Amazon SNS console, under actions button click Subscribe to topic.
37) Choose SMS under the protocol drop-down list. Enter your email in the Endpoint field and then select Create subscription.
38) Go to the email you entered and then click on the confirm subscription link.
39) Create another rule and then enter SELECT * FROM 'sensors/light'
40) Follow step 24 and click Add action again.
41) Select Send a message as an SNS push notification.
42) Choose back your *IAM role name from step 19.5 and click on Add action.
43) Click Create rule located on the Create a Rule page.
44) Run aws_pubsub.py again to receive data from your email