Skip to content

Instantly share code, notes, and snippets.

@djfav djfav/temptweet.py
Last active Nov 16, 2017

Embed
What would you like to do?
Raspberry Pi Twitter Bot Twython Script - Tweet CPU Temperature
#!/usr/bin/env python
import sys
import os
from twython import Twython
CONSUMER_KEY = 'redacted'
CONSUMER_SECRET = 'redacted'
ACCESS_KEY = 'redacted'
ACCESS_SECRET = 'redacted'
api = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET)
cmd = 'date'
time = os.popen(cmd).readline().strip()
cmd = '/opt/vc/bin/vcgencmd measure_temp'
line = os.popen(cmd).readline().strip()
temp = line.split('=')[1].split("'")[0]
tweet = 'The date and time is: ' + time + ' and my current CPU temperature is: ' + temp + ' C'
#print tweet
api.update_status(status = tweet)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.