def __init__(self): print('Fan Init') self.fan = Factory.getGpioWrapper("Buzzer", 12) self._status = 0 self.fan.off()
import time from grove.factory import Factory from grove_button import GroveButton import bluetooth buttonNotPressed = False buzzer = Factory.getGpioWrapper("Buzzer", 12) button = GroveButton(5) def on_press(t): global buttonNotPressed if (buttonNotPressed): buttonNotPressed = False client.send("Abre") else: print( "El frigorifico no esta listo para ser avierto. Espere a que su avisador suene" ) button.on_press = on_press def on_bluetooth(): global buttonNotPressed buzzer.on() time.sleep(1) buttonNotPressed = True while buttonNotPressed: time.sleep(1) print("Sleep")
import bluetooth import datetime import psutil from influxdb import InfluxDBClient vacio = False # influx configuration - edit these ifuser = "******" ifpass = "******" ifdb = "proyecto" ifhost = "grupo15" ifport = 8086 measurement_name = "system" magnet = Factory.getGpioWrapper("Electromagnet", 12) switch = GroveSwitch(18) button = GroveButton(5) def on_press(t): if (switch.state): magnet.off() print("Electromagnet apagado") else: magnet.on() global vacio vacio = False print("Electromagnet encendido")