Example #1
0
def main(callback):
    options, args, arduino = default_main(
        optparse_usage="usage: %prog [options] serial_device digital_port",
        args_validator=args_validator,
        add_options_callback=add_options_callback)

    digital_port = int(args[1])

    try:
        while True:
            value = arduino.ds18x20_read(digital_port)
            callback(value)
            if not options.loop:
                break
    except KeyboardInterrupt:
        print ""
    except Exception:
        raise
    finally:
        arduino.close()
Example #2
0
def main(callback):
    options, args, arduino = default_main(
        optparse_usage="usage: %prog [options] serial_device digital_port",
        args_validator=args_validator,
        add_options_callback=add_options_callback,
    )

    digital_port = int(args[1])

    try:
        while True:
            value = arduino.ds18x20_read(digital_port)
            callback(value)
            if not options.loop:
                break
    except KeyboardInterrupt:
        print ""
    except Exception:
        raise
    finally:
        arduino.close()
Example #3
0
def main():
    options, args, arduino = default_main(
        optparse_usage="usage: %prog [options] serial_device digital_port",
        args_validator=args_validator,
        add_options_callback=add_options_callback)

    digital_port = int(args[1])

    try:
        while True:
            temp, hum = arduino.dht11_read(digital_port)
            print "Temp: {0}C - Hum: {1}%".format(temp, hum)
            if options.loop:
                arduino.delay(500)
            else:
                break
    except KeyboardInterrupt:
        print ""
    except Exception:
        raise
    finally:
        arduino.close()
Example #4
0
def main():
    options, args, arduino = default_main(
        optparse_usage="usage: %prog [options] serial_device digital_port",
        args_validator=args_validator,
        add_options_callback=add_options_callback)

    digital_port = int(args[1])

    try:
        while True:
            temp, hum = arduino.dht11_read(digital_port)
            print "Temp: {0}C - Hum: {1}%".format(
                temp, hum)
            if options.loop:
                arduino.delay(500)
            else:
                break
    except KeyboardInterrupt:
        print ""
    except Exception:
        raise
    finally:
        arduino.close()