Пример #1
0
def main():
    # Create the relay switch object using GPIO pin 0
    relay = grove.GroveRelay(0)

    # Close and then open the relay switch 3 times,
    # waiting one second each time.  The LED on the relay switch
    # will light up when the switch is on (closed).
    # The switch will also make a noise between transitions.
    for i in range (0,3):
        relay.on()
        if relay.isOn():
            print(relay.name(), 'is on')
        time.sleep(1)
        relay.off()
        if relay.isOff():
            print(relay.name(), 'is off')
        time.sleep(1)

    # Delete the relay switch object
    del relay
Пример #2
0
#!/usr/bin/python

import paho.mqtt.client as paho
import signal
import sys
import time

from threading import Thread
from upm import pyupm_grove as grove
from upm import pyupm_biss0001 as grovemotion

luxes = grove.GroveLight(0)
motion = grovemotion.BISS0001(6)
opening = grove.GroveButton(4)
dswitch = grove.GroveRelay(2)

mqttserver = "iot.eclipse.org"
mqttport = 1883

# Sensor Luxes


def functionSensorLuxesData():
    value = luxes.value()
    print "Publish Sensor Luxes Data: We got %s!" % value
    return value


def functionSensorLuxes():
    mqttclient = paho.Client()
    mqttclient.connect(mqttserver, mqttport, 60)
Пример #3
0
#!/usr/bin/python

import paho.mqtt.client as paho
import signal
import sys
import time

from threading import Thread
from upm import pyupm_grove as grove

light = grove.GroveLight(0)
relay = grove.GroveRelay(2)

mqttserver = "iot.eclipse.org"
mqttport = 1883


def functionSubscribeLightLampData(status):
    print "Light Lamp Data %s" % status


def functionSubscribeLightLampOn(mosq, obj, msg):
    print "Subscribe Light Lamp Data!"
    if msg.payload == "ON":
        relay.on()
    elif msg.payload == "OFF":
        relay.off()
    functionSubscribeLightLampData(msg.payload)


def functionSubscribeLightLamp():
Пример #4
0
#!/usr/bin/python

# http://iotdk.intel.com/docs/master/upm/classupm_1_1_grove_button.html
# http://iotdk.intel.com/docs/master/upm/classupm_1_1_grove_relay.html

import os
import time

from threading import Thread
from upm import pyupm_grove as grove

curtainup = grove.GroveRelay(2)
curtaindown = grove.GroveRelay(3)
sensorup = grove.GroveButton(8)
sensordown = grove.GroveButton(7)
commandup = grove.GroveButton(6)
commanddown = grove.GroveButton(5)
curtainstatus = 'Stopped'

def SystemStatus():

    while True:
        #os.system('clear')
        print 'Curtain     Up: ' + str(curtainup.isOn())
        print 'Curtain   Down: ' + str(curtaindown.isOn())
        print 'Sensor      Up: ' + str(sensorup.value())
        print 'Sensor    Down: ' + str(sensordown.value())
        print ''
        print 'Curtain Status: ' + curtainstatus
        time.sleep(.5)