adafruit_ags02ma
¶
AGS02MA TVOC / Gas sensor
Author(s): ladyada
Implementation Notes¶
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- 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:
- 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 sensorimport board import busio from adafruit_ags02ma import AGS02MA
Once this is done you can define your
busio.I2C
object and define your sensor objecti2c = busio.I2C(board.SCL, board.SDA, frequency=20_000) ags = AGS02MA(i2c, address=0x1A)
Now you have access to the
gas_resistance
andTVOC
attributesres = 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
- 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