Skip to content

Instantly share code, notes, and snippets.

@gvenzl
Last active January 3, 2020 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gvenzl/25e71ba2ccab9f7693de2a74ab00aac3 to your computer and use it in GitHub Desktop.
Save gvenzl/25e71ba2ccab9f7693de2a74ab00aac3 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
# Press [Ctrl]+[C] to terminate the program
from grove.grove_air_quality_sensor_v1_3 import GroveAirQualitySensor
air_quality_sensor = GroveAirQualitySensor(0) # Pin 0 for A0
try:
while True:
# pollution ratio: 0(0.0% and best air quality) - 1000(100.0% worst air quality)
value = air_quality_sensor.value
pollution_percent = value / 10
print("Air pollution at {0:.1f}%".format(pollution_percent))
except KeyboardInterrupt:
print("Exiting program.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment