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
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)