Sensirion / arduino-sps

Arduino library for Sensirion SPS30
Other
47 stars 16 forks source link
arduino i2c particulate-matter particulates-sensors sensirion sensors sps30

Arduino library for the SPS30 particulate matter sensor

To learn more about the SPS30, please visit https://www.sensirion.com/sps30/. For support questions on the SPS30, please visit https://sensirion.com/contact.

This library is using the code from Sensirion's embedded-sps library, and adding a handful of changes to adapt to Arduino.

Most notably, for AVR based platforms (like Arduino Uno and friends), this is using an alternative I2C Master Library to work around the I2C buffer size limit that exists on those boards.

Compatibility

This library has been tested on the following platforms:

Hardware setup

Important Notes:

ESP8266 partial legacy support

This library automatically detects ESP8266 core versions 2.3.0, 2.4.0, 2.4.1 and 2.4.2 and supports a limited subset of functionality on there. The following features are not available:

Installation

Through the Arduino IDE

This library is available through Arduino IDE's Library Manager. To install, select Tools> Manage Libraries..., then search for sensirion-sps. Select the matching library and press Install.

Manual installation

For manual installation, follow these steps:

  1. Download the latest ZIP file from the Github release page
  2. Start the Arduino IDE
  3. Select Sketch > Include Library > Add .ZIP Library...
  4. A dialog will open; here, select the file you selected in step 1

Usage

Serial Monitor (Text output)

  1. Open the example from File > Examples > arduino-sps > sps30.
  2. Open the serial monitor from the Tools menu
  3. Press the "Upload" button to compile and upload the sketch

If you check the serial monitor window, you should see something like this:

Serial monitor

Serial Plotter (Graphical output)

  1. Open the example from File > Examples > arduino-sps > sps30.
  2. Open the serial plotter from the Tools menu (if you have the serial monitor open, you'll need to close it first)
  3. Uncomment line 8 of the sample program; it should now read #define PLOTTER_FORMAT
  4. Press the "Upload" button to compile and upload the sketch

If you check the serial plotter window, you should see something like this:

Serial monitor

FAQ: How PMx is defined / Why values are the same

A frequently asked question about values that are the same, which seems unlikely. However, this is due to the definition of PMx, that says that it's particles of diameter x and smaller. As such, PM10 includes all particles of diameter 10 μm and smaller, and therefore includes particles from PM4 (which itself includes particles from PM2.5). To illustrate, here's a diagram that shows this

How PMx is defined

In this example: