Paso 1: Gestión de sensores a través de Python
#! / usr/bin/env python
importar mraa, json, urllib, tiempo
sensores = ["sensor_a", "sensor_b", "sensor_c"] sensor_a = mraa. GPIO(6) sensor_b = mraa. GPIO(7) sensor_c = mraa. GPIO(8)
sensor_a.dir (mraa. DIR_OUT) sensor_b.dir (mraa. DIR_OUT) sensor_c.dir (mraa. DIR_OUT)
usuario = "bc-ef-f0-c5"
tiempos = [5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,00,1,2,3,4]
valor en tiempos: sensor_a.write (int (json.loads ((urllib.urlopen ('https://bc-ef-f0-c5.firebaseio.com/time/7:00/sensor_'+a+'.json')).read())) sensor_b.write (int (json.loads ((urllib.urlopen ('https://bc-ef-f0-c5.firebaseio.com/time/7:00/sensor_'+b+'.json')).read())) sensor_c.write (int (json.loads ((urllib.urlopen ('https://bc-ef-f0-c5.firebaseio.com/time/7:00/sensor_'+c+'.json')).read())) time.sleep(3)
Time.Sleep(10)