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

python3 -m sps30

or

from sps30 import SPS30
from time import sleep

sps = SPS30()

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

sleep(1) # let device to settle

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sps30-0.1.4.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sps30-0.1.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file sps30-0.1.4.tar.gz.

File metadata

  • Download URL: sps30-0.1.4.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for sps30-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ce35a773e133ac266b86bfcacf2d8107edeab613a2fa43e899bf5a8489378aec
MD5 60aa5a74789410398ffb08cf73fb2d93
BLAKE2b-256 fe532d5b8e7d5c8088f91f0fdde2a5f6cb59c166872ac15df9ace36fecd5b8d9

See more details on using hashes here.

File details

Details for the file sps30-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: sps30-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for sps30-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 11e5d016c663710c389c2243aa9bb009747f0a058bb1fc57e5f3b22bf85c2c47
MD5 4b569912c8fb8d8dcb94d466148f0cf0
BLAKE2b-256 b0c09fbf50df0046d8f321157ca9b82455eca778957f3b458011f692d897d5a0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page