Skip to content

Instantly share code, notes, and snippets.

Last active November 16, 2017 16:13
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
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'
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