Exemplo n.º 1
0
GPIO.setup(pin, GPIO.OUT)  ## set output

## function to save code


def activateLED(pin, delay):
    GPIO.output(pin, GPIO.HIGH)  ## set HIGH (LED ON)
    time.sleep(delay)  ## wait
    GPIO.output(pin, GPIO.LOW)  ## set LOW (LED OFF)
    return


led = False
os.system("clear")

while True:
    temp = 9.0 / 5.0 * ds18b20_read_temp() + 32
    print(temp)

    if ((temp > threshold) & (led == False)):
        activateLED(pin, ourdelay)
        led = True
    else:
        if ((led == True) & (temp < threshold)):
            led = False
            activateLED(pin, ourdelay)

    time.sleep(1)

GPIO.cleanup()  ## close down library
GPIO.setmode(GPIO.BOARD)                ## Use BOARD pin numbering
GPIO.setup(pin, GPIO.OUT)               ## set output

## function to save code

def activateLED( pin, delay ):
    GPIO.output(pin, GPIO.HIGH)           ## set HIGH (LED ON)
    time.sleep(delay)                     ## wait
    GPIO.output(pin, GPIO.LOW)            ## set LOW (LED OFF)
    return

led = False
os.system("clear")

while True:
    temp = 9.0/5.0 * ds18b20_read_temp() + 32
    print(temp)

    if ((temp > threshold) & (led == False)):
        activateLED(pin,ourdelay)
        led = True
    else:
        if ((led == True) &(temp < threshold)):
            led = False
            activateLED(pin,ourdelay)

    time.sleep(1)


GPIO.cleanup()                          ## close down library
Exemplo n.º 3
0
    altitude = sensor.read_altitude()
    slpressure = sensor.read_sealevel_pressure()
    temperature2 = sensor.read_temperature()

    if dryrun:
        print 'BMP180:'
        print 'Temp Sensor 2 = {0:0.2f} *C'.format(temperature2)
        print 'Pressure = {0:0.2f} Pa'.format(pressure)
        print 'Altitude = {0:0.2f} m'.format(altitude)
        print 'Sealevel Pressure = {0:0.2f} Pa'.format(slpressure) + '\n'
else:
    sensor,pressure,altitude,slpressure,temperature2 = 0,0,0,0,0

## DS18B20 Waterproof Temperature Probe
if useDS18B20:
    temperature3 = ds18b20_read_temp()
    if dryrun:
        print 'DS18B20:'
        print 'Temp Sensor 3 = {0:0.3f} *C'.format(temperature3) + '\n'

else:
    temperature3 = 0

## TSL2561 Lux Sensor
if useTSL2561:
    lux = luxrdr.getLux()      # Auto
    #lux = luxrdr.readLux(1)     # Low Gain
    #lux = luxrdr.readLux(16)    # High Gain

    lux = luxrdr.getLux()