A minimal library for SDS011 particulate sensors.
Project description
simple-sds011
A minimal library for reading samples from a Nova Fitness SDS011 particulate sensor.
In a nutshell
>>> import simple_sds011
>>> pm = simple_sds011.SDS011('/dev/ttyUSB0')
>>> pm.mode = simple_sds011.MODE_PASSIVE
>>> pm.period
{'type': 'period', 'value': 0, 'id': b'\xcb\xc2', 'checksum': True}
>>> pm.query()
{'type': 'sample', 'value': {'pm2.5': 8.5, 'pm10.0': 12.4}, 'id': b'\xcb\xc2', 'checksum': True}
Quick help
Writable properties
- SDS011.active: Whether the device fan and laser are powered (1) or not (0).
- SDS011.mode: Continuous (0) or passive (1) sampling. In continuous mode, the device sends sample data once a second or once a sample period. In passive mode, the device only sends sample data when queried.
- SDS011.period: The period between air samples. Can be 0 or any value between 1 and 30. The device will sleep for N * 60 - 30 seconds, then take a single sample at the end of a 30-second warm up.
Read-only properties
- SDS011.device_id: A two-byte identifier unique to the sensor.
- SDS011.firmware: The device firmware identifier.
- SDS011.port: The open serial port the device is attached to.
Commands
- SDS011.query(): Get a dictionary containing the current pm2.5 and pm10.0 levels as read by the sensor.
Caveats/to-do
- Obviously unfinished and delicate. Most useful in the interactive shell for casual readings.
- Properties are not stored in the instance, but queried to the device. If the device is not active at that moment, an exception is returned. This includes the sleep phase when period != 0.
- The continuous-report mode is not yet supported—only single queries.
- The port and ID cannot be changed.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
simple-sds011-0.0.7.tar.gz
(5.2 kB
view details)
Built Distribution
File details
Details for the file simple-sds011-0.0.7.tar.gz
.
File metadata
- Download URL: simple-sds011-0.0.7.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.1.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db7f8ff9995209d14c0cc0880829564b8b188b18b1a15701381492ae95065e0a |
|
MD5 | a3c270ddfd5a371f64f0a67571720a64 |
|
BLAKE2b-256 | 78bf3f9c85e0f14bfd8e22fd2f69254150974e72ccccbca7d37f5b1dc48c5010 |
File details
Details for the file simple_sds011-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: simple_sds011-0.0.7-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.1.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f51a039611d9a9bed8fbd9397f8a0ff58581765d2ba4ad2b70217f75ae9e518 |
|
MD5 | fe01f97d1d28ad3f50fb3f948636410d |
|
BLAKE2b-256 | 85f2512d8b76c0572cf709c3bb9d4ab1f8a7b0844cc2a5edb47f9521987d5eed |