Skip to content

Instantly share code, notes, and snippets.

@Oliviercreativ
Last active April 1, 2018 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Oliviercreativ/1cb52bbc98ad4d8fd195ccff91bae270 to your computer and use it in GitHub Desktop.
Save Oliviercreativ/1cb52bbc98ad4d8fd195ccff91bae270 to your computer and use it in GitHub Desktop.
Capturez et Tweetez en appuyant sur un bouton
import tweepy
import picamera
from time import sleep
import RPi.GPIO as GPIO
# Consumer keys and access tokens, used for OAuth
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
GPIO.setmode(GPIO.BCM)
GPIO.setup(25, GPIO.IN, GPIO.PUD_UP)
# OAuth process, using the keys and tokens
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
# Creation of the actual interface, using authentication
api = tweepy.API(auth)
with picamera.PiCamera() as camera:
camera.start_preview()
camera.annotate_text = "TweetBox by Creativpi"
while True:
GPIO.wait_for_edge(25, GPIO.FALLING)
status = 'PhotoTweet from TweetBox by Creativpi.fr'
sleep(1)
camera.capture('/home/pi/image.jpg')
api.update_with_media('/home/pi/image.jpg', status=status)
camera.stop_preview()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment