adafruit_ags02ma

AGS02MA TVOC / Gas sensor

  • Author(s): ladyada

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_ags02ma.AGS02MA(i2c_bus: I2C, address: int = 26)

Driver for the AGS02MA air quality sensor.

Warning

I2C communication rate cannot be higher than 30KHZ. Refer to https://cdn-shop.adafruit.com/product-files/5593/datasheet+ags02ma.pdf Section 3.

Parameters:
  • i2c_bus (I2C) – The I2C bus the AGS02MA is connected to.

  • address (int) – The I2C device address. Defaults to 0x1A

Raises:

RunTimeError – When the sensor could not be found

Quickstart: Importing and using the device

Here is an example of using the AGS02MA class. First you will need to import the libraries to use the sensor

import board
import busio
from adafruit_ags02ma import AGS02MA

Once this is done you can define your busio.I2C object and define your sensor object

i2c = busio.I2C(board.SCL, board.SDA, frequency=20_000)
ags = AGS02MA(i2c, address=0x1A)

Now you have access to the gas_resistance and TVOC attributes

res = ags.gas_resistance
tvoc = ags.TVOC
property TVOC: int

The calculated Total Volatile Organic Compound measurement, in ppb

Raises:

RunTimeError – When the sensor still preheating

firmware_version() int

Return 24-bit value which contains the firmware version

property gas_resistance: int

The resistance of the MEMS gas sensor

set_address(new_addr: int) None

Set the address for the I2C interface, from 0x0 to 0x7F The sensor supports modifying the I2C address. After sending this command, the new address will take effect immediately, New address will remain after powering the sensor off.

Parameters:

new_addr (int) – The new address

Raises:

ValueError: When selected address is not in the range 0x00-0x7F