コード例 #1
0
    uvlight = BrickletUVLight(UVLIGHT_UID, ipcon)
    motiondetect = BrickletMotionDetector(MOTIONDETECTOR_UID, ipcon)

    ipcon.connect(HOST, PORT)  # Connect to brickd

    while (True):
        curtime = datetime.now()
        print("Time: " + curtime.strftime('%Y/%m/%d %H:%M:%S'))

        motion = motiondetect.get_motion_detected()
        print("Motion: " + str(motion))

        illuminance = ambientlight.get_illuminance() / 10.0
        print("Illuminance: " + str(illuminance))

        uv_light = uvlight.get_uv_light()
        print("UV Light: " + str(uv_light))

        # Get current CO2 concentration (unit is ppm)
        cur_co2_concentration = co2.get_co2_concentration()
        print("CO2: " + str(cur_co2_concentration))

        # Get current sound intensity level
        cur_si = sound_intensity.get_intensity()
        print("Sound intensity: " + str(cur_si))

        # Get current dust density
        cur_dd = dust_density.get_dust_density()
        print("Dust density: " + str(cur_dd))

        # Get current humidity level
コード例 #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

HOST = "localhost"
PORT = 4223
UID = "XYZ"  # Change XYZ to the UID of your UV Light Bricklet

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_uv_light import BrickletUVLight

if __name__ == "__main__":
    ipcon = IPConnection()  # Create IP connection
    uvl = BrickletUVLight(UID, ipcon)  # Create device object

    ipcon.connect(HOST, PORT)  # Connect to brickd
    # Don't use device before ipcon is connected

    # Get current UV light (unit is µW/cm²)
    uv_light = uvl.get_uv_light()
    print("UV Light: " + str(uv_light) + " µW/cm²")

    raw_input("Press key to exit\n")  # Use input() in Python 3
    ipcon.disconnect()