You are reading a single comment by @cyclotron3k and its replies.
Click here to read the full conversation.
-
Yep, just wired directly to it via jumper cables.
I didn't worry about any of that, nope.This is the relay I used:
https://www.sainsmart.com/products/2-channel-5v-relay-module
Python side:
import boto3 from time import sleep import json import sys import traceback import RPi.GPIO as GPIO from time import sleep import datetime as dt from subprocess import call # Set up SQS sqs = boto3.resource('sqs') queue = sqs.Queue('QUEUE_URI') # Set up S3 s3 = boto3.resource('s3'); # Set up GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(24, GPIO.OUT) GPIO.output(24, GPIO.HIGH) GPIO.setup(25, GPIO.OUT) GPIO.output(25, GPIO.HIGH) def takeAndStorePicture(name): call(['fswebcam', '-q', '--rotate', '180', '-r', '640x360', '--jpeg', '80', '--timestamp', '%D %T (%Z)', name]) obj = s3.Object('BUCKET_NAME', name).upload_file(name, ExtraArgs={ 'ACL': 'public-read' }) def relayOnOff(side): if side == 'left': channel = 24 if side == 'right': channel = 25 GPIO.output(channel, GPIO.LOW) sleep(1) GPIO.output(channel, GPIO.HIGH) def main(): try: while(True): messages = queue.receive_messages() for message in messages: print 'Message: ' + message.body j = json.loads(message.body) takeAndStorePicture('before.jpg') relayOnOff(j['Message']) message.delete() sleep(10) takeAndStorePicture('after.jpg') sleep(1) except KeyboardInterrupt: print "Shutdown requested...exiting" except Exception: traceback.print_exc(file=sys.stdout) GPIO.cleanup(); sys.exit(0) if __name__ == "__main__": main()
cyclotron3k
pascalo
I built myself a garage door opener with an old raspberry pi and a two switch relay wired up to the roller door motors that have an external switch port.
Custom Android app to set off AWS lambda call to SNS to SQS, which a little process on the pi consumes and uses the GPIO port to trigger the relays. Takes a pic of before and after via webcam, uploads to s3, so I can view that in the app, too.