If you already have Arduino board hanging around and would like to create your own PM2.5 / PM10 particulate sensor, here’s a recipe on how to do this. Note that I have pulled together a lot of other resources from the web that were badly organised here into one document. My code is based heavily on code from DFRobot.com’s sample code (all references included at the end of this post).
Here’s a photo of the setup, with the 16×2 LCD at left, the prototype shield and mini-breadboard on the Arduino Uno, and the Plantower PMS3003 on the right.
What you will need to create your Pollution sensor
- Arduino Uno board
- Plantower PMS 3003 sensor (or any other from their range, however note there may be code changes required – see later)
- A 16×2 LCD display, compatible with the LiquidCrystal display Arduino library.
- Highly recommended: prototype shield and mini breadboard, some jumper wires.
Given that these components are now heavily commoditised, I would recommend finding a reliable vendor on eBay for these components directly from China (i.e. one with a lot of positive reviews).
Setup instructions for your Pollution sensor
- Obtain the sketch from my GitHub repository (see below)
- Wire it up:
- Wiring the Plantower sensor: If you didn’t buy the breakout board, I recommend cutting and stripping the wires and solder ends to them to use them with the breadboard. Check the PDF in my GitHub repository for the pin outs on the PMS 3003 sensor, unfortunately red and black do not necessarily correspond with VCC and GND.
- Wiring the LCD: use the Sparkfun tutorial for guidance on the wiring plus also the resistor and pot required to adjust the LCD contrast.
- Make the following customisations to my code to match your requirements:
- Serial buffer read length constant (Line 12): This is crucial. Depending on your sensor, Plantower sends out data in either 32 bytes or 24 bytes. For example, if you have a PMS3003, you will need to set this to 23 (24 byte readout, remaining byte is for the header). If you have a PMS1001, you’ll need to set this to 31. Check the datasheets of the Plantower sensor to verify what you require.
- LiquidCrystal constructor (Line 19): Make sure that the pins match the pin outs of your LCD. I didn’t use the standard pinouts of the tutorial, so change it if required.
- Uncomment lines 62-82 to debug: These lines write values to the serial port of the Arduino, that you can monitor through the IDE. This is useful to debug the output of the sensor (and to verify that you are decoding its output correctly).
- Important note whilst uploading to the Arduino: Since the Plantower sensor is wired into the TX/RX pins of the Arduino, this can interfere with uploading your sketch to the board. Unplug the sensor whilst you are uploading, then plug it back in after.
Common problems with your pollution sensor
- If your readout is zero, this probably indicates a problem with the serial buffer read length. I would download the data sheet and check Line 12. Uncomment lines 62-82 and use the Arduino Serial Monitor to debug.
My GitHub project with the code and data sheets can be found here: https://github.com/pakmingw/ArduinoPlantowerSensor
- This Arduino forum post was a good starting point: https://forum.arduino.cc/index.php?topic=355922.0
- Plantower’s website: http://www.plantower.com/
- DFRobot’s Plantower sample code (of which I have based my code very heavily on). https://www.dfrobot.com/wiki/index.php/PM2.5_laser_dust_sensor_SKU:SEN0177
- Sparkfun’s 16×2 LCD Tutorial (for the LCD code example and wiring diagram) https://www.sparkfun.com/tutorials/251