Skip to content

Instantly share code, notes, and snippets.

@makvoid
Created February 21, 2022 04:47
Show Gist options
  • Save makvoid/3c82c04cce83a52f90eb47e80b2dfca5 to your computer and use it in GitHub Desktop.
Save makvoid/3c82c04cce83a52f90eb47e80b2dfca5 to your computer and use it in GitHub Desktop.
AHT20 collect method
@click.command()
@click.option('--location', required=True, help='Sensor location name')
def collect(location):
# Collect data and convert/round
temperature = round_num(c_to_f(sensor.temperature))
humidity = round_num(sensor.relative_humidity)
# Save entry
try:
save_entry(location, temperature, humidity)
except Exception as e:
# Print error traceback
print(traceback.format_exc())
sys.exit(1)
print('Entry saved:', temperature, 'F,', humidity, '% H')
if __name__ == '__main__':
collect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment