Python-based driver for Sensirion SPS30 particulate matter sensor over I2C
Project description
Sensirion SPS30
Introduction
Python-based driver for Sensirion SPS30 particulate matter sensor. Tested on Raspberry Pi Zero/Zero W/3B+/4B.
Wiring
Sensor
Pin 1 Pin 5
| |
V V
.------------------------------------------------.
| .-----------. |
| | x x x x x | |
| '-----------' |
| [] [] [] [] |
'------------------------------------------------'
| Pin | Description | UART | I2C |
|---|---|---|---|
| 1 | Supply voltage 5V | VDD | VDD |
| 2 | UART receiving pin/ I2C serial data input/ output | RX | SDA |
| 3 | UART transmitting pin/ I2C serial clock input | TX | SCL |
| 4 | Interface select (UART: floating (NC) /I2C: GND) | NC | GND |
| 5 | Ground | GND | GND |
I2C Interface
Sensor Pins Raspberry Pi Pins
.-------.-----. .----------.---------.
| Pin 1 | VDD |-----------------------------| 5V | Pin 2/4 |
| Pin 2 | SDA |-----------------------------| I2C1 SDA | Pin 3 |
| Pin 3 | SCL |-----------------------------| I2C1 SCL | Pin 5 |
| Pin 4 | GND |-----. | | |
| Pin 5 | GND |-----'-----------------------| GND | Pin 6/9 |
'-------'-----' '----------'---------'
Example
Default parameters of SPS30 class
| Parameter | Value | Description |
|---|---|---|
| bus | 1 | I2C bus of Raspberry Pi |
| address | 0x69 | Default I2C address |
import sys
import json
from time import sleep
from sps30 import SPS30
if __name__ == "__main__":
pm_sensor = SPS30()
print(f"Firmware version: {pm_sensor.firmware_version()}")
print(f"Product type: {pm_sensor.product_type()}")
print(f"Serial number: {pm_sensor.serial_number()}")
print(f"Status register: {pm_sensor.read_status_register()}")
print(
f"Auto cleaning interval: {pm_sensor.read_auto_cleaning_interval()}s")
print(f"Set auto cleaning interval: {pm_sensor.write_auto_cleaning_interval_days(2)}s")
pm_sensor.start_measurement()
while True:
try:
print(json.dumps(pm_sensor.get_measurement(), indent=2))
sleep(2)
except KeyboardInterrupt:
print("Stopping measurement...")
pm_sensor.stop_measurement()
sys.exit()
Output data format
{
"sensor_data": {
"mass_density": {
"pm1.0": 1.883,
"pm2.5": 3.889,
"pm4.0": 6.232,
"pm10": 6.7
},
"particle_count": {
"pm0.5": 1.302,
"pm1.0": 4.595,
"pm2.5": 7.326,
"pm4.0": 7.864,
"pm10": 7.967
},
"particle_size": 1.63,
"mass_density_unit": "ug/m3",
"particle_count_unit": "#/cm3",
"particle_size_unit": "um"
},
"timestamp": 1630217804
}
Dependencies
None
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sensirion_sps30-0.1.0.tar.gz
(10.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sensirion_sps30-0.1.0.tar.gz.
File metadata
- Download URL: sensirion_sps30-0.1.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cfbe6acdc4caae9bef8cd2acdfd7c5b033cb9cbdc7c9c79f625cabaa6ff699c
|
|
| MD5 |
cf4cbfd5c9d25555e140561a7bf2ea95
|
|
| BLAKE2b-256 |
228f6aabaf019ddfe4a2b64a04b32e64b20d41a3ba8f7aee3bfbf0d6f7c3f84d
|
File details
Details for the file sensirion_sps30-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sensirion_sps30-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb5d58588e994b9aab9307e264b6c9761bf13293dda855317a1d1efb48152846
|
|
| MD5 |
18580920f6de0e977ec03fb6a4972652
|
|
| BLAKE2b-256 |
08ec81bdb49746b7a754e7afd632c5b3981566ceb184ada8162b7ed279adebb3
|