https://github.com/tomasz-lewicki/pms7003
A minimal python interface for PMS7003 PM sensor
https://github.com/tomasz-lewicki/pms7003
air-pollution air-quality pms7003 raspberry-pi
Last synced: 3 months ago
JSON representation
A minimal python interface for PMS7003 PM sensor
- Host: GitHub
- URL: https://github.com/tomasz-lewicki/pms7003
- Owner: tomasz-lewicki
- License: mit
- Created: 2018-10-08T16:16:10.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-04T09:04:00.000Z (almost 4 years ago)
- Last Synced: 2025-01-10T16:30:36.423Z (10 months ago)
- Topics: air-pollution, air-quality, pms7003, raspberry-pi
- Language: Python
- Homepage:
- Size: 628 KB
- Stars: 21
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# A minimalistic python interface for PMS7003 sensor
The code reads PM values from serial port. Tested on Raspberry Pi, but it should work on any machine with Python and serial port.
Device description:
## Setup
To install the driver, simply do:
```bash
pip3 install pms7003
```
## Usage example
```python
from pms7003 import Pms7003Sensor, PmsSensorException
if __name__ == '__main__':
sensor = Pms7003Sensor('/dev/serial0')
while True:
try:
print(sensor.read())
except PmsSensorException:
print('Connection problem')
sensor.close()
```
The read function has an option of returning values as a dict or OrderedDict.
```python
sensor.read(ordered=True)
```
## Usage example with threading:
```python
import time
from pms7003 import Pms7003Thread
if __name__ == "__main__":
with Pms7003Thread("/dev/serial0") as sensor:
while True:
print(sensor.measurements)
# We're free to do computation in main thread
a = 2**32
time.sleep(1)
```