Even though the use of post cards are becoming a rarity it is still predominantly used in India. Unlike gmail It isn't easy to keep a checking on the post box every hour as it involves physical labour. Enter AWS Services, with AWS IOT and Amazon Push Notification Service, it makes this problem completely trivial to solve, merging the physical and digital worlds.
Concept:
The CAD model shows a slit through which mail arrives. The idea is to detect the entry condition of the mail by change in light when the path between the LED light source and the LDR is interrupted.
Platform Used:
AWS IOT and SNS: AWS IOT makes it convenient and secure to connect devices in a reliable manner. Here we use MQTT to authenticate and communicate with the AWS IOT Resources. MQTT is a machine to machine protocol used predominantly in IOT applications. AWS IOT acts as the MQTT broker with the python code on the Intel Galileo Gen 2 acting as the MQTT client enabling secure communication.
Grove Starter Kit: This project uses the LDR and LED from the Groove starter kit by Seed Studio. It houses a shield in arduino form-factor enabling rapid prototyping in a simple plug and play manner.
Setting Up AWS IOT and SNS:
Of all the services offered we are choosing AWS IOT today.
After traversing through the getting started page click on create a resource
Now create a thing. All machines are consider things in AWS IOT and need authentication to communicate with the AWS IOT resources.
Name the resource appropriately and click create
After creating we can see that no certificate is attached so click on connect a device.
Even though we are using python in Intel Galileo we have to use NodeJs to generate the certificate files necessary for authentication.
Download the certificate files and observe the json formatted structure shown which will be used when programming the client.
Lets setup SNS for receiving push notifications.
Create a topic and Enter the topic name and Subject of the mail.
Now subscribe the mail address and verify it.
Once you clicked on the confirm subscription you can now receive push notifications.
To test it let us publish a message just for the kicks of it.
Fill in the message and click on publish.
Yeah! I got my mail.
Now that we created a our machine lets create the link between AWS IOT and SNS for that we need to create a rule.
Now fill the details according to your preferences the most important among them is the topic filter which forces it to list to a particular topic.
Now lets authenticate it by creating a new role.
Among the choose action drop down list box choose SNS.
The role name is then set.
Verify the details of the SNS topic set.
Now every time we get a post, a push notification will be generated.
Setting up Intel Galileo Gen 2:
You can set up Intel Galileo Gen 2 on Mac using the following link:
https://software.intel.com/en-us/programming-blank-sd-card-with-yocto-linux-image-os-x
The main steps are outlined here:
1. Format your 8GB SD card:
2. Use the dd command to write Intel Yocto dev-kit image to the appropriate disk:
3. Once Booted Set Up USB Wifi using Connmanctl as shown below:
4. Configure the nameservers of connmanctl:
connmanctl config your_wireless_card_as_used_above --nameservers 8.8.8.8 8.8.4.4
5. Setting up Pip:
curl -L "https://bootstrap.pypa.io/get-pip.py" > get-pip.py
python get-pip.py
6. Install MQTT:
pip install paho-mqtt
7. Setup WiringX86 for GPIO control:
curl -O -L http://github.com/emutex/wiring-x86/archive/master.tar.gz
tar zxvf master.tar.gz
cd wiring-x86-master/
sudo python setup.py install
Using MQTT Client for Debugging:
AWS IOT hosts an MQTT client to facilitate easy debugging. Lets check if what we hacked together is working.
Click on MQTT client on the AWS IOT Console and choose the appropriate topic you want to listen to. Here it is topics/ldr
The python script is run on Intel Galileo Gen 2
The MQTT client on AWS starts receiving messages.
Setting up certificates:
In addition to the certificates downloaded from AWS IOT console you also need to download the following file. The document structure should as shown:
curl https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem > rootCA.pem
Also use scp to transfer the files from Mac to Intel Galileo Gen 2.
Threshold:
The LDR value drops drastically we the light path from the led is cut hence from experimentation I found that instead of setting up a threshold if the instantaneous difference is greater than 300 a mail is triggered. You can customise the message you want to display on the mail using the payload option in the mqtt.publish function.
Mission Accomplished :)
Comments