PMS5003 Particulate Matter Sensor Test Run
Tags: csharp, python, raspberrypi, beginners
Published: 2021-04-12 17:10:16

---
title: PMS5003 Particulate Matter Sensor Test Run
published: true
description: Taking the PMS5003 sensor for a spin!
tags: csharp, python, raspberrypi, beginner
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjs4huofmlkmg9r1f301.jpg
---

Hi

In this article we’ll test out the PMS5003 sensor in order to see if it works. I’ve forgot to buy a connector board, so we will do a manual connection to the Raspberry Pi 3 B V2. This involves cutting the wires and adding some resistors.

Please note that you need:

- 5 Jumper Wires
- 2 Resistors 10K Ohm

## Raspberry Pi Setup

Before connecting the sensor to the Pi we need to configure the Pi for this usecase.

"Note that if you’re using this sensor with Raspberry Pi, then you’ll need to make a couple of changes to its configuration. Type sudo raspi-config in the terminal and then under “Interfacing options” and “Serial” disable the login shell and enable the serial port hardware. Edit your /boot/config.txt file and add the lines enable_uart=1 and dtoverlay=pi3-miniuart-bt to the bottom of the file." _[Source](https://shop.pimoroni.com/products/pms5003-particulate-matter-sensor-with-cable)_

After the setup from above is done, reboot the Pi and install the software.

```bash
sudo pip install pms5003
git clone https://github.com/pimoroni/pms5003-python
```

Note: In order to connect to the Raspberry Pi I’ve used [Visual Studio Code](https://code.visualstudio.com/) and the [Remote – SSH](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh), this is unnecessary, editing files is VSCode is a personal preference.

## Sensor Wiring

To identify the sensor’s wires I’ve consulted the [PMS5003 specification](https://www.aqmd.gov/docs/default-source/aq-spec/resources-page/plantower-pms5003-manual_v2-3.pdf) and I’ve cut my sensor’s Picoblade connector, this enabled me to use jumper wires and attach my 10K ohms resistors to the wires. Then I’ve isolated the wires using some electrical tape.

![pins](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vnobvofm2heeoq3vwrb9.png)

![sensor with cables](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/15e1xavnrwapkhqkpo65.jpg)

After that, I’ve connected the sensor to the Pi using the following diagram:

![circuit diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxx31heuxucxlid2zuuh.png)

Note: I’ve connected PIN 3 and PIN 6 to a 10K ohm pull up resistor at 3.3V because at the moment I don’t know if I need to reset the sensor or put it to sleep.

![pi pins](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wj4lmnq7m2xpabet1k0u.png)

To simplify things further:

- SENSOR 1 (VCC) -> RPI 5V
- SENSOR 2 (GND) -> RPI Ground
- SENSOR 3 & 6 (SET & RESET) -> 10k OHM -> RPI 3.3V
- SENSOR 4 (RXD) -> RPI Gpio 14 (UART TX)
- SENSOR 6 (TXD) -> RPI Gpio 15 (UART RX)

That’s it! It will look something like the following.

![complete wiring](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjs4huofmlkmg9r1f301.jpg)

Verify that the sensor is connected then ssh into the Pi and run the all.py example from pms5003-python. You should see something like:

![sensor readings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r970od8d077l7to58w0.png)

The results can be interpreted using the following [reference table](https://aqicn.org/sensor/pms5003-7003/).

![reading table](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfdx4p94wnmeymvywi14.png)

---

If you're like myself and ❤️ C#, I’ve released library for interfacing with the PMS5003 (Particulate Matter Sensor) via UART.

The code is available on [Github](https://github.com/dnutiu/pms5003) and the package is available on [NuGet](https://www.nuget.org/packages/PMS5003/).

Thanks for reading!