Skip to content

Commit a784a4c

Browse files
authored
Merge pull request #17 from jposada202020/improving_docs
Improving docs, adding products to the related products API
2 parents 48b57ec + 5abc81d commit a784a4c

File tree

4 files changed

+99
-5
lines changed

4 files changed

+99
-5
lines changed

adafruit_pm25/__init__.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
1919
Works with most (any?) Plantower UART or I2C interfaced PM2.5 sensor.
2020
21+
* `PM2.5 Air Quality Sensor and Breadboard Adapter Kit - PMS5003
22+
<https://www.adafruit.com/product/3686>`_
23+
24+
* `PM2.5 Air Quality Sensor with I2C Interface - PMSA003I
25+
<https://www.adafruit.com/product/4505>`_
26+
27+
* `Adafruit PMSA003I Air Quality Breakout
28+
<https://www.adafruit.com/product/4632>`_
29+
2130
**Software and Dependencies:**
2231
2332
* Adafruit CircuitPython firmware for the supported boards:
@@ -33,8 +42,13 @@
3342

3443

3544
class PM25:
36-
"""Super-class for generic PM2.5 sensors. Subclasses must implement
37-
_read_into_buffer to fill self._buffer with a packet of data"""
45+
"""
46+
Super-class for generic PM2.5 sensors.
47+
48+
.. note::
49+
Subclasses must implement _read_into_buffer to fill self._buffer with a packet of data
50+
51+
"""
3852

3953
def __init__(self):
4054
# rad, ok make our internal buffer!

adafruit_pm25/i2c.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
1717
**Hardware:**
1818
19+
* `PM2.5 Air Quality Sensor with I2C Interface - PMSA003I
20+
<https://www.adafruit.com/product/4505>`_
21+
22+
* `Adafruit PMSA003I Air Quality Breakout
23+
<https://www.adafruit.com/product/4632>`_
24+
25+
1926
Works with most (any?) Plantower I2C interfaced PM2.5 sensor.
2027
2128
**Software and Dependencies:**
@@ -36,6 +43,38 @@
3643
class PM25_I2C(PM25):
3744
"""
3845
A module for using the PM2.5 Air quality sensor over I2C
46+
47+
:param i2c_bus: The `busio.I2C` object to use.
48+
:param ~microcontroller.Pin reset_pin: Pin use to reset the sensor. Defaults to `None`
49+
:param int address: The I2C address of the device. Defaults to :const:`0x12`
50+
51+
**Quickstart: Importing and using the PMSA003I Air quality sensor**
52+
53+
Here is one way of importing the `PM25_I2C` class so you can use it with the name ``pm25``.
54+
First you will need to import the libraries to use the sensor
55+
56+
.. code-block:: python
57+
58+
import board
59+
import busio
60+
from adafruit_pm25.i2c import PM25_I2C
61+
62+
Once this is done you can define your `busio.I2C` object and define your sensor object
63+
64+
.. code-block:: python
65+
66+
i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)
67+
reset_pin = None
68+
pm25 = PM25_I2C(i2c, reset_pin)
69+
70+
71+
Now you have access to the air quality data using the class function
72+
`adafruit_pm25.PM25.read`
73+
74+
.. code-block:: python
75+
76+
aqdata = pm25.read()
77+
3978
"""
4079

4180
def __init__(self, i2c_bus, reset_pin=None, address=0x12):

adafruit_pm25/uart.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
1919
Works with most (any?) Plantower UART or I2C interfaced PM2.5 sensor.
2020
21+
* `PM2.5 Air Quality Sensor and Breadboard Adapter Kit - PMS5003
22+
<https://www.adafruit.com/product/3686>`_
23+
24+
2125
**Software and Dependencies:**
2226
2327
* Adafruit CircuitPython firmware for the supported boards:
@@ -33,6 +37,40 @@
3337
class PM25_UART(PM25):
3438
"""
3539
A driver for the PM2.5 Air quality sensor over UART
40+
41+
:param ~busio.UART uart: The `busio.UART` object to use.
42+
:param ~microcontroller.Pin reset_pin: Pin use to reset the sensor.
43+
Defaults to `None`
44+
45+
46+
**Quickstart: Importing and using the PMS5003 Air quality sensor**
47+
48+
Here is one way of importing the `PM25_UART` class so you
49+
can use it with the name ``pm25``.
50+
First you will need to import the libraries to use the sensor
51+
52+
.. code-block:: python
53+
54+
import board
55+
import busio
56+
from adafruit_pm25.uart import PM25_UART
57+
58+
Once this is done you can define your `busio.UART` object and define
59+
your sensor object
60+
61+
.. code-block:: python
62+
63+
uart = busio.UART(board.TX, board.RX, baudrate=9600)
64+
reset_pin = None
65+
pm25 = PM25_UART(uart, reset_pin)
66+
67+
Now you have access to the air quality data using the class function
68+
`adafruit_pm25.PM25.read`
69+
70+
.. code-block:: python
71+
72+
aqdata = pm25.read()
73+
3674
"""
3775

3876
def __init__(self, uart, reset_pin=None):
@@ -61,6 +99,3 @@ def _read_into_buffer(self):
6199
if not remain or len(remain) != 31:
62100
raise RuntimeError("Unable to read from PM2.5 (incomplete frame)")
63101
self._buffer[1:] = remain
64-
65-
66-
# print([hex(i) for i in self._buffer])

docs/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ Table of Contents
2626
.. toctree::
2727
:caption: Related Products
2828

29+
PM2.5 Air Quality Sensor with I2C Interface - PMSA003I <https://www.adafruit.com/product/4505>
30+
31+
Adafruit PMSA003I Air Quality Breakout <https://www.adafruit.com/product/4632>
32+
33+
PM2.5 Air Quality Sensor and Breadboard Adapter Kit - PMS5003 <https://www.adafruit.com/product/3686>
34+
2935
.. toctree::
3036
:caption: Other Links
3137

0 commit comments

Comments
 (0)