API Documentation
SPS30
Sps30Device
The class Sps30DeviceBase implements the low level interface of the sensor. The class Sps30Device extends the Sps30DeviceBase. It provides additional functions to ease the use of the sensor.
- class sensirion_i2c_sps30.device.Sps30DeviceBase(channel)[source]
Low level API implementation of SPS30
- property channel
- start_measurement(measurement_output_format)[source]
Starts the measurement. After power up, the module is in Idle-Mode. Before any measurement values can be read, the Measurement-Mode needs to be started using this command.
- Parameters:
measurement_output_format – Possible enum values: output_format_float, output_format_uint16
Note
This command can only be executed in Idle-Mode.
- Example:
sensor.start_measurement(OutputFormat(1280))
- read_data_ready_flag()[source]
This command can be used for polling to find out when new measurements are available. The pointer address only has to be set once. Repeated read requests get the status of the Data-Ready Flag.
- Return data_ready_flag:
0x0000: no new measurements available 0x0001: new measurements ready to read
- read_measurement_values_uint16()[source]
Reads the measured values from the sensor module and resets the “Data-Ready Flag”. If the sensor module is in Measurement-Mode, an updated measurement value is provided every second and the “Data-Ready Flag” is set. If no synchronized readout is desired, the “Data-Ready Flag” can be ignored. The command “Read Measured Values” always returns the latest measured values.
- Return mc_1p0:
Mass Concentration PM1.0 [µg/m³]
- Return mc_2p5:
Mass Concentration PM2.5 [µg/m³]
- Return mc_4p0:
Mass Concentration PM4.0 [µg/m³]
- Return mc_10p0:
Mass Concentration PM10.0 [µg/m³]
- Return nc_0p5:
Number Concentration PM0.5 [#/cm³]
- Return nc_1p0:
Number Concentration PM1.0 [#/cm³]
- Return nc_2p5:
Number Concentration PM2.5 [#/cm³]
- Return nc_4p0:
Number Concentration PM4.0 [#/cm³]
- Return nc_10p0:
Number Concentration PM10.0 [#/cm³]
- Return typical_particle_size:
Typical Particle Size [µm]
Note
Use this function when the measurement output format is configured to: “Big-endian unsigned 16-bit integer values”
- read_measurement_values_float()[source]
Reads the measured values from the sensor module and resets the “Data-Ready Flag”. If the sensor module is in Measurement-Mode, an updated measurement value is provided every second and the “Data-Ready Flag” is set. If no synchronized readout is desired, the “Data-Ready Flag” can be ignored. The command “Read Measured Values” always returns the latest measured values.
- Return mc_1p0:
Mass Concentration PM1.0 [µg/m³]
- Return mc_2p5:
Mass Concentration PM2.5 [µg/m³]
- Return mc_4p0:
Mass Concentration PM4.0 [µg/m³]
- Return mc_10p0:
Mass Concentration PM10.0 [µg/m³]
- Return nc_0p5:
Number Concentration PM0.5 [#/cm³]
- Return nc_1p0:
Number Concentration PM1.0 [#/cm³]
- Return nc_2p5:
Number Concentration PM2.5 [#/cm³]
- Return nc_4p0:
Number Concentration PM4.0 [#/cm³]
- Return nc_10p0:
Number Concentration PM10.0 [#/cm³]
- Return typical_particle_size:
Typical Particle Size [µm]
Note
Use this function when the measurement output format is configured to: “Big-endian IEEE754 float values”
- sleep()[source]
Enters the Sleep-Mode with minimum power consumption. This will also deactivate the I2C interface.
Note
This command can only be executed in Idle-Mode.
- wake_up()[source]
In Sleep-Mode the I2C interface is disabled and must first be activated by sending a low pulse on the SDA line. A low pulse can be generated by sending a I2C-Start-Condition followed by a Stop-Condition. If then a Wake-up command follows within 100ms, the module will switch on again and is ready for further commands in the Idle-Mode. If the low pulse is not followed by the Wake-up command, the microcontroller returns after 100ms to Sleep-Mode and the interface is deactivated again.
Alternatively, if the software implementation does not allow to send a I2C-Start-Condition followed by a Stop-Condition, the Wake-up command can be sent twice in succession. In this case the first Wake-up command is ignored, but causes the interface to be activated.
- start_fan_cleaning()[source]
Starts fan cleaning manually
Note
This command can only be executed in Measurement-Mode.
- read_auto_cleaning_interval()[source]
Reads auto cleaning interval of the periodic fan-cleaning
- Return auto_cleaning_interval:
Interval in seconds
- write_auto_cleaning_interval(auto_cleaning_interval)[source]
Writes auto cleaning interval of the periodic fan-cleaning
- Parameters:
auto_cleaning_interval – Interval in seconds
Note
For FW Version < 2.2: After writing a new interval, this will be activated immediately. However, if the interval register is read out after setting the new value, the previous value is returned until the next start/reset of the sensor module.
- Example:
sensor.write_auto_cleaning_interval(604800)
- read_product_type()[source]
This command returns the product type. It is defined as a string value with a length of 8 ASCII characters (excluding terminating null-character)
- Return product_type:
8-byte ASCII string
- read_serial_number()[source]
This command returns the serial number. It is defined as a string value with a maximum length of 32 ASCII characters (including terminating null-character)
- Return serial_number:
32-byte ASCII string
- read_firmware_version()[source]
Gets firmware major.minor firmware version.
- Return major_version:
- Return minor_version:
- read_device_status_register()[source]
Use this command to read the device status register. For more details, check explanations given in chapter 4.4 of the datasheet.
- Return device_status:
Commands
The transfer classes specify the data that is transferred between host and sensor. The generated transfer classes are used by the driver class and not intended for direct use.
- class sensirion_i2c_sps30.commands.OutputFormat(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
- OUTPUT_FORMAT_FLOAT = 768
- OUTPUT_FORMAT_UINT16 = 1280
- class sensirion_i2c_sps30.commands.StartMeasurement(measurement_output_format)[source]
Starts the measurement. After power up, the module is in Idle-Mode. Before any measurement values can be read, the Measurement-Mode needs to be started using this command.
- CMD_ID = 16
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_sps30.commands.StopMeasurement[source]
Use this command to return to the Idle-Mode.
- CMD_ID = 260
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_sps30.commands.ReadDataReadyFlag[source]
This command can be used for polling to find out when new measurements are available. The pointer address only has to be set once. Repeated read requests get the status of the Data-Ready Flag.
- CMD_ID = 514
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
- class sensirion_i2c_sps30.commands.ReadMeasurementValuesUint16[source]
Reads the measured values from the sensor module and resets the “Data-Ready Flag”. If the sensor module is in Measurement-Mode, an updated measurement value is provided every second and the “Data-Ready Flag” is set. If no synchronized readout is desired, the “Data-Ready Flag” can be ignored. The command “Read Measured Values” always returns the latest measured values.
- CMD_ID = 768
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
- class sensirion_i2c_sps30.commands.ReadMeasurementValuesFloat[source]
Reads the measured values from the sensor module and resets the “Data-Ready Flag”. If the sensor module is in Measurement-Mode, an updated measurement value is provided every second and the “Data-Ready Flag” is set. If no synchronized readout is desired, the “Data-Ready Flag” can be ignored. The command “Read Measured Values” always returns the latest measured values.
- CMD_ID = 768
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
- class sensirion_i2c_sps30.commands.Sleep[source]
Enters the Sleep-Mode with minimum power consumption. This will also deactivate the I2C interface.
- CMD_ID = 4097
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_sps30.commands.WakeUp[source]
In Sleep-Mode the I2C interface is disabled and must first be activated by sending a low pulse on the SDA line. A low pulse can be generated by sending a I2C-Start-Condition followed by a Stop-Condition. If then a Wake-up command follows within 100ms, the module will switch on again and is ready for further commands in the Idle-Mode. If the low pulse is not followed by the Wake-up command, the microcontroller returns after 100ms to Sleep-Mode and the interface is deactivated again.
Alternatively, if the software implementation does not allow to send a I2C-Start-Condition followed by a Stop-Condition, the Wake-up command can be sent twice in succession. In this case the first Wake-up command is ignored, but causes the interface to be activated.
- CMD_ID = 4355
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_sps30.commands.StartFanCleaning[source]
Starts fan cleaning manually
- CMD_ID = 22023
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_sps30.commands.ReadAutoCleaningInterval[source]
Reads auto cleaning interval of the periodic fan-cleaning
- CMD_ID = 32772
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
- class sensirion_i2c_sps30.commands.WriteAutoCleaningInterval(auto_cleaning_interval)[source]
Writes auto cleaning interval of the periodic fan-cleaning
- CMD_ID = 32772
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_sps30.commands.ReadProductType[source]
This command returns the product type. It is defined as a string value with a length of 8 ASCII characters (excluding terminating null-character)
- CMD_ID = 53250
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
- class sensirion_i2c_sps30.commands.ReadSerialNumber[source]
This command returns the serial number. It is defined as a string value with a maximum length of 32 ASCII characters (including terminating null-character)
- CMD_ID = 53299
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
- class sensirion_i2c_sps30.commands.ReadFirmwareVersion[source]
Gets firmware major.minor firmware version.
- CMD_ID = 53504
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
- class sensirion_i2c_sps30.commands.ReadDeviceStatusRegister[source]
Use this command to read the device status register. For more details, check explanations given in chapter 4.4 of the datasheet.
- CMD_ID = 53766
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
Result Types
The signal classes specify transformations of the raw sensor signals into a meaningful units. The generated signal types are used by the driver class and not intended for direct use.