Skip to main content

SPS30 PM Sensor I2C Driver for Python3

SPS30 is a Particulate Matter sensor manufactured by Sensirion. It is capable to measure 10 different value of particles. With this driver, you can use SPS30 with Python3 over I2C.

Dependencies

Only smbus2 other than Python.

Installation

pip3 install sps30

Usage

From command line;

run-sps30

From Python script;

from sps30 import SPS30
from time import sleep

sps = SPS30(1)

if sps.read_article_code() == sps.ARTICLE_CODE_ERROR:
    raise Exception("ARTICLE CODE CRC ERROR!")
else:
    print("ARTICLE CODE: " + str(sps.read_article_code()))

if sps.read_device_serial() == sps.SERIAL_NUMBER_ERROR:
    raise Exception("SERIAL NUMBER CRC ERROR!")
else:
    print("DEVICE SERIAL: " + str(sps.read_device_serial()))

sps.set_auto_cleaning_interval(seconds) # default 604800, set 0 to disable auto-cleaning

sps.device_reset() # device has to be powered-down or reset to check new auto-cleaning interval

if sps.read_auto_cleaning_interval() == sps.AUTO_CLN_INTERVAL_ERROR: # or returns the interval in seconds
    raise Exception("AUTO-CLEANING INTERVAL CRC ERROR!")
else:
    print("AUTO-CLEANING INTERVAL: " + str(sps.read_auto_cleaning_interval()))

sps.start_measurement()

while not sps.read_data_ready_flag():
    print("New Measurement is not available!")
    if sps.read_data_ready_flag() == sps.DATA_READY_FLAG_ERROR:
        raise Exception("DATA-READY FLAG CRC ERROR!")

if sps.read_measured_values() == sps.MEASURED_VALUES_ERROR:
    raise Exception("MEASURED VALUES CRC ERROR!")
else:
    print ("PM1.0 Value in µg/m3: " + str(sps.dict_values['pm1p0']))
    print ("PM2.5 Value in µg/m3: " + str(sps.dict_values['pm2p5']))
    print ("PM4.0 Value in µg/m3: " + str(sps.dict_values['pm4p0']))
    print ("PM10.0 Value in µg/m3: " + str(sps.dict_values['pm10p0']))
    print ("NC0.5 Value in 1/cm3: " + str(sps.dict_values['nc0p5']))    # NC: Number of Concentration 
    print ("NC1.0 Value in 1/cm3: " + str(sps.dict_values['nc1p0']))
    print ("NC2.5 Value in 1/cm3: " + str(sps.dict_values['nc2p5']))
    print ("NC4.0 Value in 1/cm3: " + str(sps.dict_values['nc4p0']))
    print ("NC10.0 Value in 1/cm3: " + str(sps.dict_values['nc10p0']))
    print ("Typical Particle Size in µm: " + str(sps.dict_values['typical']))	

sps.stop_measurement()

sps.start_fan_cleaning() # enables fan-cleaning manually for 10 seconds (referred by datasheet)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Metadata

Release files for sps30 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sps30 0.1.10
File Size Uploaded Provenance Actions
sps30-0.1.10.tar.gz 3.9 kB Without provenance Details for sps30-0.1.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sps30 0.1.10
File Interpreter ABI Platform Actions
sps30-0.1.10-py3-none-any.whl Python 3 none any Details for sps30-0.1.10-py3-none-any.whl

Total release size: 9.6 kB

Release files / sps30-0.1.10.tar.gz

Download URL sps30-0.1.10.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a080c1b3d7c8c704c2d5f6efa6dddadc2f6f1932021207e4f4744e5e5db3e837
BLAKE2b-256 checksum
How to use checksums
f49de2b43208ad3d6dcfd1fc9384645f935861aa9da0f8a2602989a2e0c54f31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

Release files / sps30-0.1.10-py3-none-any.whl

Download URL sps30-0.1.10-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50b5facce6de93758a5e5745d205067c413123d52cc4cf9a5553242a745ddad0
BLAKE2b-256 checksum
How to use checksums
dd4bf1b88af1d1579b4271f8a27a3663c147ebffed33ddf31437e72b84a4edf4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

Security for sps30 0.1.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page