Sibi Sankar
Published © GPL3+

Virtual Post Man.

Virtual Post Man maps the physical event of receiving a post card to an email notification thus bridging the digital and physical worlds.

IntermediateFull instructions provided1,764
Virtual Post Man.

Things used in this project

Story

Read more

Custom parts and enclosures

Post Box

The necessary dimensions of the post box is identified using model of Intel Galileo Gen 2.

Schematics

Circuit Connection

The groove starter kit makes it trivial to set it up.

Code

MQTT Client.

Python
After the necessary dependancies are met (ie) Placing the essential certificates in the auth folder the python works its magic.
# Library Imports
import paho.mqtt.client as mqtt
import ssl
import time
import thread
import pyupm_grove as grove
from wiringx86 import GPIOGalileoGen2 as GPIO

# Pin Definition
led = 5
light = grove.GroveLight(0)

# Stores the Previous LDR value
prev_ldr_data = 0

gpio = GPIO()
gpio.pinMode(led, gpio.OUTPUT)

#Set it to always on
gpio.digitalWrite(led, gpio.HIGH)

#defining topics
ldrTopic    = "topics/ldr"

def on_connect(client, userdata, flags, rc):
    print "Connected Successfully"

client = mqtt.Client()
client.on_connect = on_connect
client.tls_set(ca_certs='./auth/rootCA.pem', certfile='./auth/XXXXXXXXXX-certificate.pem.crt', keyfile='./auth/XXXXXXXXXX-private.pem.key', tls_version=ssl.PROTOCOL_SSLv23)
client.tls_insecure_set(True)
client.connect("XXXXXXXXXXXXXX.iot.us-west-2.amazonaws.com", 8883, 60) #Taken from REST API endpoint



#Main Loop
#Publishing Analog Values to AWS
def publishNewPost(Variable):
    while (1):
        ldr_data = str(light.raw_value() )
        if prev_ldr_data:
            if ldr_data - prev_ldr_data > 300:
                client.publish(ldr_Topic, payload="A New Mail For You")
                print "Threshold crossed "
        prev_ldr_data = ldr_data



thread.start_new_thread(publishNewPost,("publishNewPost",))
client.loop_forever()

Credits

Sibi Sankar

Sibi Sankar

2 projects • 7 followers
I live by the maxim 'made made dane' (you still have a long way to go).

Comments