Skip to main content
Engineering LibreTexts

Grove Air Quality Sensor

  • Page ID
    51680
  •  

    Grove Air Quality Sensor.png

    The grove air quality sensor is an analog device.

    Therefore it interfaces through an analog port.  The required input voltage is 3.3 to 5 volts.

    Save the script with the name air_quality_sensor.py.

     

    #!/usr/bin/python3
    
    import time
    from grove.grove_air_quality_sensor_v1_3 import GroveAirQualitySensor
             # mport the sensor library and name it GroveAirQualitySensor for this script.
    # connect to analog pin 0(slot A0)
    PIN = 0
    # Set the port (pin) to use for analog input.
    sensor = GroveAirQualitySensor(PIN) # Make a sensor object set to the analog pin input.
    
    print('Detecting ...')
    while True:             # Using while true makes this an infinite loop.  Use Ctrl-C to exit the loop.
      value = sensor.value
      if value > 100:
        print("{}, High Pollution.".format(value)) # The if else block.
      else:
        print("{}, Air Quality OK.".format(value))
      time.sleep(.1)        # Sleep for X seconds.
    

     

    This is what the output looks like when a swap of hand sanitizer (Ethyl Alcohol 62%) is placed over the sensor.

    75, Air Quality OK.
    76, Air Quality OK.
    79, Air Quality OK.
    81, Air Quality OK.
    84, Air Quality OK.
    87, Air Quality OK.
    91, Air Quality OK.
    93, Air Quality OK.
    97, Air Quality OK.
    100, Air Quality OK.
    104, High Pollution.
    105, High Pollution.
    108, High Pollution.
    110, High Pollution.
    113, High Pollution.
    117, High Pollution.
    119, High Pollution.
    121, High Pollution.
    125, High Pollution.
    129, High Pollution.
    

    The recovery after removing the swap.

    110, High Pollution.
    110, High Pollution.
    108, High Pollution.
    108, High Pollution.
    108, High Pollution.
    106, High Pollution.
    102, High Pollution.
    102, High Pollution.
    101, High Pollution.
    101, High Pollution.
    100, Air Quality OK.
    99, Air Quality OK.
    97, Air Quality OK.
    98, Air Quality OK.
    96, Air Quality OK.
    94, Air Quality OK.
    94, Air Quality OK.
    94, Air Quality OK.
    92, Air Quality OK.
    91, Air Quality OK.
    91, Air Quality OK.
    90, Air Quality OK.
    

     

     

     

     

    • Was this article helpful?