コード例 #1
0
def initialize_sensors(info_config):
    """Do all setup operations necesary to get ready prior to recording data.
    """

    # Config data.
    pins_data = info_config['pins_data']

    pin_power = int(info_config['pin_power'])

    # Initialize GPIO.
    # dht22.SetupGpio()

    # Power up the sensors.
    if pin_power:
        dht22._pinMode(pin_power, dht22._OUTPUT)
        dht22._digitalWrite(pin_power, True)
        time.sleep(5)

    # Create data recording channels.
    channels, queue = sensors.start_channels(pins_data)

    ok = sensors.check_channels_ok(channels, verbose=True)

    if not ok:
        sensors.stop_channels(channels)
        raise ValueError('Data channels not ready.')

    # Done.
    return channels, queue
コード例 #2
0
def initialize_sensors(info_config):
    """Do all setup operations necesary to get ready prior to recording data.
    """

    # Config data.
    pins_data = info_config['pins_data']

    pin_power = int(info_config['pin_power'])

    # Initialize GPIO.
    # dht22.SetupGpio()

    # Power up the sensors.
    if pin_power:
        dht22._pinMode(pin_power, dht22._OUTPUT)
        dht22._digitalWrite(pin_power, True)
        time.sleep(5)

    # Create data recording channels.
    channels, queue = sensors.start_channels(pins_data)

    ok = sensors.check_channels_ok(channels, verbose=True)

    if not ok:
        sensors.stop_channels(channels)
        raise ValueError('Data channels not ready.')

    # Done.
    return channels, queue
コード例 #3
0
def finalize(channels, info_config):
    """
    Do all operations necesary to shutdown.
    """

    # Stop recording.
    if channels:
        sensors.stop_channels(channels)

    # Turn off the sensors.
    if info_config:
        if info_config['pin_power']:
            print('pin_power off')
            dht22._digitalWrite(info_config['pin_power'], False)
コード例 #4
0
def finalize(channels, info_config):
    """
    Do all operations necesary to shutdown.
    """

    # Stop recording.
    if channels:
        sensors.stop_channels(channels)

    # Turn off the sensors.
    if info_config:
        if info_config['pin_power']:
            print('pin_power off')
            dht22._digitalWrite(info_config['pin_power'], False)
コード例 #5
0
def power_cycle(channels, info_config, time_off=30):
    """
    Power cycle all conected sensors.

    time_off: sleep time in seconds.
    """

    if not info_config['pin_power']:
        # Nothing to do.
        pass
    else:
        # Do it.
        sensors.pause_channels(channels)

        time.sleep(0.01)
        dht22._digitalWrite(info_config['pin_power'], False)

        time.sleep(time_off)

        dht22._digitalWrite(info_config['pin_power'], True)
        time.sleep(0.01)

        sensors.unpause_channels(channels)
コード例 #6
0
def power_cycle(channels, info_config, time_off=30):
    """
    Power cycle all conected sensors.

    time_off: sleep time in seconds.
    """

    if not info_config['pin_power']:
        # Nothing to do.
        pass
    else:
        # Do it.
        sensors.pause_channels(channels)

        time.sleep(0.01)
        dht22._digitalWrite(info_config['pin_power'], False)

        time.sleep(time_off)

        dht22._digitalWrite(info_config['pin_power'], True)
        time.sleep(0.01)

        sensors.unpause_channels(channels)