1 / 9

Motion Activated Twitter Webcam

Motion Activated Twitter Webcam. Douglas Drobny University of Idaho. Objective. Detect motion through an Arduino Board Use Python to take a picture with the default windows webcam Post the image to a Twitter account Relatively inexpensive (goal: $80). Budget. Arduino Uno $30

jacqui
Download Presentation

Motion Activated Twitter Webcam

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Motion Activated Twitter Webcam Douglas Drobny University of Idaho

  2. Objective • Detect motion through an Arduino Board • Use Python to take a picture with the default windows webcam • Post the image to a Twitter account • Relatively inexpensive (goal: $80)

  3. Budget • Arduino Uno $30 • Parallax PIR sensor $11 • Breadboard $ 8 • Webcam ~$20 • Total Price: $59

  4. Arduino Uno R-3 • Uses the ATmega16U2 Architecture • USB or 7-12V power • void loop(){val= digitalRead(inputPin); if (val == HIGH) {digitalWrite(ledPin, HIGH); if (pirState == LOW) {Serial.println("Motion detected!");pirState= HIGH; } } else { if (pirState == HIGH){Serial.println("Motion ended!");pirState= LOW; }

  5. Motion Sensor • First try: Generic PIR Motion Sensor • Sparkfun.com • Does not regulate its own voltage • Complex wiring • Second Try: Parallax PIR Motion Sensor • Internal LED that light up on motion detection • 1:1 wiring

  6. Taking the image • Responds to input on a COM port • Uses the PySerial library • ser =serial.Serial('/./COM3‘, timeout=1) • line =ser.readline() • Takes an image • Uses VideoCapture library • from VideoCapture import Device cam = Device() cam.saveSnapshot('image.jpg')

  7. Twitter Authentication • Requires 4 keys • Consumer Key • Consumer Key Secret • Created when adding an App on twitter.com • Access Token • Access Token Secret • Created when user gives permission to an App

  8. Tweepy • Supports the new Oauth authentication for Twitter • Does not support uploading files in a Tweet • https://github.com/laiso/tweepy does • api = tweepy.API('consumer key', 'consumer key secret‘, 'access token', 'access token secret‘) • api.status_update_with_media(filename, text)

  9. Results • https://twitter.com/#!/ScadaProject • It works! • Issues: • Motion sensor detects motion wider than camera range • Motion sensor light isn’t very sneaky • Too many images quickly to Twitter can error out some posts

More Related