|
| 1 | +# Arduino library for the SPS30 particulate matter sensor |
| 2 | + |
| 3 | +To learn more about the SPS30, please visit https://www.sensirion.com/sps30/. |
| 4 | +For support questions on the SPS30, please visit https://sensirion.com/contact. |
| 5 | + |
| 6 | +This library is using the code from Sensirion's |
| 7 | +[embedded-sps](https://github.com/Sensirion/embedded-sps) library, and adding a |
| 8 | +handful of changes to adapt to Arduino. |
| 9 | + |
| 10 | +Most notably, for AVR based platforms (like Arduino Uno and friends), this is |
| 11 | +using an alternative |
| 12 | +[I2C Master Library](https://github.com/DSSCircuits/I2C-Master-Library) to work |
| 13 | +around the I2C buffer size limit that exists on those boards. |
| 14 | + |
| 15 | +## Compatibility |
| 16 | + |
| 17 | +This library has been tested on the following platforms: |
| 18 | +- AVR based Arduino, like Arduino Uno |
| 19 | +- ESP8266, using v2.5.0 or newer (Tested on Adafruit Feather Huzzah ESP8266) |
| 20 | +- ESP32, using v1.0.1 or newer (Tested on Adafruit Feather Huzzah ESP32) |
| 21 | +- SAMD (tested on Arduino MKR 1010) |
| 22 | + |
| 23 | +## Hardware setup |
| 24 | + |
| 25 | +**Important Notes:** |
| 26 | + |
| 27 | +* The SPS30 requires 5V supply voltage +/-0.5V in order to provide correct |
| 28 | + output values; the SPS30 should be compatible with 3.3V I2C levels, so as |
| 29 | + long as the supply voltage is correct the SPS30 should work fine with 3.3V |
| 30 | + setups |
| 31 | +* Make sure that the SPS30's Pin 4 ("Interface select") is connected to GND, on |
| 32 | + power-up of the sensor, otherwise the sensor works in UART instead of I2C |
| 33 | + mode and this driver will not detect the sensor. Note that the |
| 34 | + interface-select configuration is read on every start of the sensor including |
| 35 | + after a soft-reset. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +### ESP8266 partial legacy support |
| 40 | + |
| 41 | +This library automatically detects ESP8266 core versions 2.3.0, 2.4.0, 2.4.1 and |
| 42 | +2.4.2 and supports a limited subset of functionality on there. The following |
| 43 | +features are not available: |
| 44 | +- Reading out number concentrations, |
| 45 | +- Reading out the average particle size |
| 46 | +- Reading out the serial number |
| 47 | + |
| 48 | +## Installation |
| 49 | + |
| 50 | +### Through the Arduino IDE |
| 51 | + |
| 52 | +This library is available through Arduino IDE's Library Manager. To install, |
| 53 | +select ```Tools```> ```Manage Libraries...```, then search for |
| 54 | +```sensirion-sps```. Select the matching library and press ```Install```. |
| 55 | + |
| 56 | +### Manual installation |
| 57 | + |
| 58 | +For manual installation, follow these steps: |
| 59 | + |
| 60 | +1. Download the latest ZIP file from the |
| 61 | + [Github release page](https://github.com/Sensirion/arduino-sps/releases/latest) |
| 62 | +1. Start the Arduino IDE |
| 63 | +1. Select ```Sketch > Include Library > Add .ZIP Library...``` |
| 64 | +1. A dialog will open; here, select the file you selected in step 1 |
| 65 | + |
| 66 | +## Usage |
| 67 | + |
| 68 | +### Serial Monitor (Text output) |
| 69 | + |
| 70 | +1. Open the example from ```File > Examples > arduino-sps > sps30```. |
| 71 | +1. Open the serial monitor from the Tools menu |
| 72 | +1. Press the "Upload" button to compile and upload the sketch |
| 73 | + |
| 74 | +If you check the serial monitor window, you should see something like this: |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +### Serial Plotter (Graphical output) |
| 79 | + |
| 80 | +1. Open the example from ```File > Examples > arduino-sps > sps30```. |
| 81 | +1. Open the serial plotter from the Tools menu (if you have the serial monitor |
| 82 | + open, you'll need to close it first) |
| 83 | +1. Uncomment line 8 of the sample program; it should now read |
| 84 | + ```#define PLOTTER_FORMAT``` |
| 85 | +1. Press the "Upload" button to compile and upload the sketch |
| 86 | + |
| 87 | +If you check the serial plotter window, you should see something like this: |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +## FAQ: How PMx is defined / Why values are the same |
| 94 | + |
| 95 | +A frequently asked question about values that are the same, which seems unlikely. However, this is due to the definition of PM_x_, 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 |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | +In this example: |
| 100 | +- PM2.5 would be 3.1 μg/m^3 |
| 101 | +- PM4 would be 3.2 μg/m^3 (3.1 particles [2.5 and smaller] + 0.1 [>2.5, <= 4.0]) |
| 102 | +- PM10 would be 3.2 μg/m^3 (3.1 particles [2.5 and smaller] + 0.1 [>2.5, <= 4.0] + 0 [>4.0 <= 10]) |
0 commit comments