diff --git a/adafruit_pm25/__init__.py b/adafruit_pm25/__init__.py index 0a55447..201fff0 100644 --- a/adafruit_pm25/__init__.py +++ b/adafruit_pm25/__init__.py @@ -18,6 +18,15 @@ Works with most (any?) Plantower UART or I2C interfaced PM2.5 sensor. +* `PM2.5 Air Quality Sensor and Breadboard Adapter Kit - PMS5003 + `_ + +* `PM2.5 Air Quality Sensor with I2C Interface - PMSA003I + `_ + +* `Adafruit PMSA003I Air Quality Breakout + `_ + **Software and Dependencies:** * Adafruit CircuitPython firmware for the supported boards: @@ -33,8 +42,13 @@ class PM25: - """Super-class for generic PM2.5 sensors. Subclasses must implement - _read_into_buffer to fill self._buffer with a packet of data""" + """ + Super-class for generic PM2.5 sensors. + + .. note:: + Subclasses must implement _read_into_buffer to fill self._buffer with a packet of data + + """ def __init__(self): # rad, ok make our internal buffer! diff --git a/adafruit_pm25/i2c.py b/adafruit_pm25/i2c.py index 09a4e10..21a2dc8 100644 --- a/adafruit_pm25/i2c.py +++ b/adafruit_pm25/i2c.py @@ -16,6 +16,13 @@ **Hardware:** +* `PM2.5 Air Quality Sensor with I2C Interface - PMSA003I + `_ + +* `Adafruit PMSA003I Air Quality Breakout + `_ + + Works with most (any?) Plantower I2C interfaced PM2.5 sensor. **Software and Dependencies:** @@ -36,6 +43,38 @@ class PM25_I2C(PM25): """ A module for using the PM2.5 Air quality sensor over I2C + + :param i2c_bus: The `busio.I2C` object to use. + :param ~microcontroller.Pin reset_pin: Pin use to reset the sensor. Defaults to `None` + :param int address: The I2C address of the device. Defaults to :const:`0x12` + + **Quickstart: Importing and using the PMSA003I Air quality sensor** + + Here is one way of importing the `PM25_I2C` class so you can use it with the name ``pm25``. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + import busio + from adafruit_pm25.i2c import PM25_I2C + + Once this is done you can define your `busio.I2C` object and define your sensor object + + .. code-block:: python + + i2c = busio.I2C(board.SCL, board.SDA, frequency=100000) + reset_pin = None + pm25 = PM25_I2C(i2c, reset_pin) + + + Now you have access to the air quality data using the class function + `adafruit_pm25.PM25.read` + + .. code-block:: python + + aqdata = pm25.read() + """ def __init__(self, i2c_bus, reset_pin=None, address=0x12): diff --git a/adafruit_pm25/uart.py b/adafruit_pm25/uart.py index e5b28a7..fc28c27 100644 --- a/adafruit_pm25/uart.py +++ b/adafruit_pm25/uart.py @@ -18,6 +18,10 @@ Works with most (any?) Plantower UART or I2C interfaced PM2.5 sensor. +* `PM2.5 Air Quality Sensor and Breadboard Adapter Kit - PMS5003 + `_ + + **Software and Dependencies:** * Adafruit CircuitPython firmware for the supported boards: @@ -33,6 +37,40 @@ class PM25_UART(PM25): """ A driver for the PM2.5 Air quality sensor over UART + + :param ~busio.UART uart: The `busio.UART` object to use. + :param ~microcontroller.Pin reset_pin: Pin use to reset the sensor. + Defaults to `None` + + + **Quickstart: Importing and using the PMS5003 Air quality sensor** + + Here is one way of importing the `PM25_UART` class so you + can use it with the name ``pm25``. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + import busio + from adafruit_pm25.uart import PM25_UART + + Once this is done you can define your `busio.UART` object and define + your sensor object + + .. code-block:: python + + uart = busio.UART(board.TX, board.RX, baudrate=9600) + reset_pin = None + pm25 = PM25_UART(uart, reset_pin) + + Now you have access to the air quality data using the class function + `adafruit_pm25.PM25.read` + + .. code-block:: python + + aqdata = pm25.read() + """ def __init__(self, uart, reset_pin=None): @@ -61,6 +99,3 @@ def _read_into_buffer(self): if not remain or len(remain) != 31: raise RuntimeError("Unable to read from PM2.5 (incomplete frame)") self._buffer[1:] = remain - - -# print([hex(i) for i in self._buffer]) diff --git a/docs/index.rst b/docs/index.rst index 67af7cd..f111b3c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -26,6 +26,12 @@ Table of Contents .. toctree:: :caption: Related Products + PM2.5 Air Quality Sensor with I2C Interface - PMSA003I + + Adafruit PMSA003I Air Quality Breakout + + PM2.5 Air Quality Sensor and Breadboard Adapter Kit - PMS5003 + .. toctree:: :caption: Other Links