venerdì 13 gennaio 2012

Datalogger + Twetter

Una versione del Datalogger con salvataggio su Twetter (poco utile a fini scientifici). Dalle prime prove  la latenza di Twetter e' decisamente superiore a quella di GDocs

---------------------------------------------------------------------------------------------

import android, time, tweepy
from time import strftime


CONSUMER_KEY = 'xxxxxxxxx'
CONSUMER_SECRET = 'xxxxxxxxxxxxx'
ACCESS_KEY = 'xxxxxxxxxxxxxxxx'
ACCESS_SECRET = 'xxxxxxxxxxxxxxxxxxx'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)


droid = android.Android()


droid.startSensingTimed(1,1000)
time.sleep(3)
acq = 0
while True:
accx = str(droid.sensorsReadAccelerometer().result[0])
accy = str(droid.sensorsReadAccelerometer().result[1])
accz = str(droid.sensorsReadAccelerometer().result[2])
az = str(droid.sensorsReadOrientation().result[0])
pitch = str(droid.sensorsReadOrientation().result[1])
roll =  str(droid.sensorsReadOrientation().result[2])
orario = strftime("%Y-%m-%d %H:%M:%S")

outString = "Azimuth: " + az + " Pitch: " + pitch + " Roll: " + roll + " - " + orario
api.update_status(outString)


acq = acq + 1
print "Dato " + str(acq)
time.sleep(30)


droid.stopSensing()
---------------------------------------------------------------------------------------------


Nessun commento:

Posta un commento

Perche' investire su Unix

 Un libro trovato nel libero scambio alla Coop su cio' che poteva essere e non e' stato...interessante la storia su Unix del primo c...