def main(): # Instantiate a Grove Motion sensor on GPIO pin D2 myMotion = upmMotion.BISS0001(2) ## Exit handlers ## # This function stops python from printing a stacktrace when you hit control-C def SIGINTHandler(signum, frame): raise SystemExit # This function lets you run code on exit, including functions from myMotion def exitHandler(): print "Exiting" sys.exit(0) # Register exit handlers atexit.register(exitHandler) signal.signal(signal.SIGINT, SIGINTHandler) # Read the value every second and detect motion while (1): if (myMotion.value()): print "Detecting moving object" else: print "No moving objects detected" time.sleep(1)
#importa bibliotecas #Biblioteca LCD RGB import pyupm_i2clcd as lcd #Biblioteca del sensor pirolico import pyupm_biss0001 as upm_motion import time #Se inicializa el sensor pirolico en el puerto 2 motion = upm_motion.BISS0001(2) #Direccion del LCD RGB myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62) myLcd.clear() myLcd.setColor(255, 255, 0) myLcd.write("Activando") time.sleep(1) myLcd.setCursor(0, 0) while 1: myLcd.clear() if (motion.value()): #Cada que detecte algo el sensor pirolico myLcd.setColor(180, 0, 0) myLcd.write("Movimiento") else: #Cada que no detecte algo el sensor pirolico myLcd.setColor(0, 180, 0) myLcd.write("No movimiento") time.sleep(.5)
def getMotion(self, pin=7): if self.motion is None: # Instantiate a Grove Motion sensor on GPIO pin D7 self.motion = upmMotion.BISS0001(pin) return self.getProxyObject(self.motion)
import time, sys, signal, atexit import pyupm_rfr359f as upmRfr359f import pyupm_biss0001 as upmMotion # Instantiate an RFR359F digital pin D2 # This was tested on the Grove IR Distance Interrupter myDistInterrupter = upmRfr359f.RFR359F(2) myMotion = upmMotion.BISS0001(3) ## Exit handlers ## # This function stops python from printing a stacktrace when you hit control-C def SIGINTHandler(signum, frame): raise SystemExit # This function lets you run code on exit, including functions from myDistInterrupter def exitHandler(): print "Exiting" sys.exit(0) # Register exit handlers atexit.register(exitHandler) signal.signal(signal.SIGINT, SIGINTHandler) while(1): if (myDistInterrupter.objectDetected()): print "Object detected" else: print "Area is clear" if (myMotion.value()):
#!/usr/bin/python import paho.mqtt.client as paho import time import pyupm_biss0001 from threading import Thread motion = pyupm_biss0001.BISS0001(6) def functionDataSensor(): return motion.value() def functionDataSensorMqttPublish(): mqttclient = paho.Client() mqttclient.connect("iot.eclipse.org", 1883, 60) while True: data = functionDataSensor() topic = "edzna/principal/motion" mqttclient.publish(topic, data) time.sleep(1) if __name__ == '__main__': threadmqttpublish = Thread(target=functionDataSensorMqttPublish) threadmqttpublish.start() print "Hello Edzna @ Motion"
def __init__(self, threshold = 0.4): # GPIO pin D2 self.motion = upmMotion.BISS0001(2) self.state = 0 self.average = 0 self.threshold = threshold
import time import pyupm_biss0001 as upmMotion movimiento = upmMotion.BISS0001(2) while (1): if (movimiento.value()): print("Movimiento detectado") else: print("No se ha detectado movimiento") time.sleep(1)
import dweepy, mraa, random, psutil,time,datetime, pyupm_grove as grove, pyupm_mic as upmMicrophone, IoT import pyupm_biss0001 as upmMotion dateString = '%d/%m/%Y %H:%M:%S' from Queue import Queue from threading import Thread import threading # The Gpio pins are number to the MRAA mapping, # the Intel Edison uses Intel Brekout Board layout on the DFRomeo board LEDRight = mraa.Gpio(33) # Setting LEDRight to pin 7 Green LED LEDLeft = mraa.Gpio(37) # Setting LEDLeft to pin 13 (White LED) pir = upmMotion.BISS0001(38) # Setting PIR motion sensor to pin 11 servoTilt = mraa.Pwm(14) # Setting Tilt sero to pin 5 servoPan = mraa.Pwm(20) # Setting Pan sero to pin 3 # What to do at pin (input / Output) LEDRight.dir(mraa.DIR_OUT) LEDLeft.dir(mraa.DIR_OUT) servoTilt.period_us(10000) servoPan.period_us(10000) runForever = True; def listener(publisher_thread): print "listener thread..." for dweet in dweepy.listen_for_dweets_from('canary30_iot'):