Interfacing PMS5003 PM2.5 Air Quality Sensor with Arduino
In this tutorial, we learn how to interface PMS5003 PM2.5 Air Quality Sensor with Arduino. We will make a simple Arduino Code and measure the dust particle concentration in the air with size and quantity for PM1.0, PM2.5, and PM10. PMS5003 is a kind of digital and universal particle concentration sensor, which can be used to obtain the number of suspended particles in the air, i.e. the concentration of particles, and output of them in the form of digital interface.
Check the advanced version of this project here: IoT Based Air Pollution/Quality Monitoring with ESP8266
Overview
PM2.5 and PM10 refer to particulate matter with particle diameter up to 2.5 microns and 10 microns respectively and are among the most dangerous air pollutants. Due to their small size, PM2.5 particles can travel deep into the human lung and cause a variety of health issues; for instance, by triggering asthma attacks or contributing to cardiovascular disease.
High concentrations of dust or PM is a serious health concern. PM2.5 is less than 2.5 microns in diameter, and PM10 is less than 10 microns in diameter. This means a PM10 report includes PM2.5 as well. Both these particles are much smaller than a human hair, which is about 70 microns in width.
PM10: Operations such as stone crushing, coal grinding, rotary kilning in the cement industry, and dust on road stirred by moving vehicles can increase PM10 levels. PM10 limit for 24-hour average is 150µg/m3.
PM2.5: This is a result of fine particles produced from all types of combustion, including motor vehicles, thermal power plants, residential wood burning, forest fires, agricultural burning, and other industrial processes. PM2.5 limit for 24-hour average is 35µg/m3.
So for measuring the Particulate Matter size of PM1.0, PM2.5 & PM10 we are using Plantpower PMS5003 Dust Sensor. You can also use other Plantpower PMS x003 Sensor like PMS1003, PMS3003, PMS5003, PMS6003 & PMS7003.The code given below supports all these models with Arduino.
Bill of Materials
You need to purchase the following components if you want to make this project. All the components can be saily purchased from Amazon.
S.N.Components QuantityPurchase Links
1Arduino UNO Board1Amazon | AliExpress
2PMS5003 PM2.5/PM10 Sensor1Amazon | AliExpress
320×4 LCD Display1Amazon | AliExpress
4Potentiometer 10K1Amazon | AliExpress
5Connecting Wires10Amazon | AliExpress
6Breadboard1Amazon | AliExpress
PMS5003 Air Quality Sensor
Overview
The Plantower PMS5003 is a low-cost laser particle counter, one of a range of sensors by Plantower that also include the PMS1003, PMS3003, and PMS7003. PMS5003 is a kind of digital and universal particle concentration sensor, which can be used to obtain the number of suspended particles in the air, i.e. the concentration of particles, and output them in the form of a digital interface. This sensor can be inserted into variable instruments related to the concentration of suspended particles in the air or other environmental improvement equipment to provide correct concentration data in time.
Working Principle
Laser scattering principle is used for such sensor, i.e. produce scattering by using a laser to radiate suspending particles in the air, then collect scattering light in a certain degree, and finally obtain the curve of scattering light change with time. In the end, equivalent particle diameter and the number of particles with different diameters per unit volume can be calculated by microprocessor-based on MIE theory.
PM5003 Pins
Some of the PM2.5 pins are numbered from left to right as 1, 2, 3……8. But in case of PM5003, the pins are named from right to left. Be careful while connecting PM5003 pins as you might connect it reversely.
Pin
Function
Description
Remarks
1
VCC
Supply voltage 5V
4.5 – 5.5V
2
GND
Ground
3
SET
HIGH or SUSPENDED – work mode
LOW – sleep mode
3.3V logic
4
RXD
UART/TTL data recieve
3.3V logic
5
TXD
UART/TTL data transmit
3.3V logic
6
Reset
LOW to reset
3.3V logic
7
NC
Not connected
8
NC
Not connected
Some of the PMSx003 Sensors comes with connectors like shown below:
In case if you don’t have the connector with you, then simply you can cut the connector with the scissors and solder the hard wire that can be inserted easily on Arduino Board or breadboard.
Interfacing PMS5003 PM2.5 Air Quality Sensor with Arduino
The interfacing of PMS5003 with Arduino is pretty easy. You just need 4 connections. Connect PIN1 VCC of PMS5003 to Arduino 5V Pin and PIN2 GND to GND of Arduino. The UART Pin, i.e PIN4 Rx & PIN5 Tx is connected to Arduino pin 3 & 4 respectively as shown in the figure below.
The Plantower sensors output serial data at 9600 baud that can be read by many computers and can be connected to a PC via a USB adaptor such as this USB 2.0 to TTL UART Serial Converter CP2102.
Source Code/Program
The source code for interfacing PM2.5 PMS5003 with Arduino is given below. Simply copy the code and upload to the Arduino UNO Board.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <SoftwareSerial.h>
SoftwareSerial
pmsSerial
(
2
,
3
)
;
void
setup
(
)
{
// our debugging output
Serial
.
begin
(
115200
)
;
// sensor baud rate is 9600
pmsSerial
.
begin
(
9600
)
;
}
struct
pms5003data
{
uint16_t
framelen
;
uint16_t
pm10_standard
,
pm25_standard
,
pm100_standard
;
uint16_t
pm10_env
,
pm25_env
,
pm100_env
;
uint16_t
particles_03um
,
particles_05um
,
particles_10um
,
particles_25um
,
particles_50um
,
particles_100um
;
uint16_t
unused
;
uint16_t
checksum
;
}
;
struct
pms5003data
data
;
void
loop
(
)
{
if
(
readPMSdata
(
&pmsSerial)) {
// reading data was successful!
Serial.println();
Serial
.
println
(
“—————————————“
)
;
Serial
.
println
(
“Concentration Units (standard)”
)
;
Serial
.
(
“PM 1.0: “
)
;
Serial
.
(
data
.
pm10_standard
)
;
Serial
.
(
“\t\tPM 2.5: “
)
;
Serial
.
(
data
.
pm25_standard
)
;
Serial
.
(
“\t\tPM 10: “
)
;
Serial
.
println
(
data
.
pm100_standard
)
;
Serial
.
println
(
“—————————————“
)
;
Serial
.
println
(
“Concentration Units (environmental)”
)
;
Serial
.
(
“PM 1.0: “
)
;
Serial
.
(
data
.
pm10_env
)
;
Serial
.
(
“\t\tPM 2.5: “
)
;
Serial
.
(
data
.
pm25_env
)
;
Serial
.
(
“\t\tPM 10: “
)
;
Serial
.
println
(
data
.
pm100_env
)
;
Serial
.
println
(
“—————————————“
)
;
Serial
.
(
“Particles > 0.3um / 0.1L air:”
)
;
Serial
.
println
(
data
.
particles_03um
)
;
Serial
.
(
“Particles > 0.5um / 0.1L air:”
)
;
Serial
.
println
(
data
.
particles_05um
)
;
Serial
.
(
“Particles > 1.0um / 0.1L air:”
)
;
Serial
.
println
(
data
.
particles_10um
)
;
Serial
.
(
“Particles > 2.5um / 0.1L air:”
)
;
Serial
.
println
(
data
.
particles_25um
)
;
Serial
.
(
“Particles > 5.0um / 0.1L air:”
)
;
Serial
.
println
(
data
.
particles_50um
)
;
Serial
.
(
“Particles > 10.0 um / 0.1L air:”
)
;
Serial
.
println
(
data
.
particles_100um
)
;
Serial
.
println
(
“—————————————“
)
;
}
}
boolean
readPMSdata
(
Stream *
s
)
{
if
(
!
s
–
>
available
(
)
)
{
return
false
;
}
// Read a byte at a time until we get to the special ‘0x42’ start-byte
if
(
s
–
>
peek
(
)
!
=
0x42
)
{
s
–
>
read
(
)
;
return
false
;
}
// Now read all 32 bytes
if
(
s
–
>
available
(
)
<
32
)
{
return
false
;
}
uint8_t
buffer
[
32
]
;
uint16_t
sum
=
0
;
s
–
>
readBytes
(
buffer
,
32
)
;
// get checksum ready
for
(
uint8_t
i
=
0
;
i
<
30
;
i
++
)
{
sum
+=
buffer
[
i
]
;
}
/* debugging
for (uint8_t i=2; i<32; i++) {
Serial.print(“0x”); Serial.print(buffer[i], HEX); Serial.print(“, “);
}
Serial.println();
*/
// The data comes in endian’d, this solves it so it works on all platforms
uint16_t
buffer_u16
[
15
]
;
for
(
uint8_t
i
=
0
;
i
<
15
;
i
++
)
{
buffer_u16
[
i
]
=
buffer
[
2
+
i*
2
+
1
]
;
buffer_u16
[
i
]
+=
(
buffer
[
2
+
i*
2
]
<
<
8
)
;
}
// put it into a nice struct 🙂
memcpy
(
(
void
*
)
&data, (void *)buffer_u16, 30);
if
(
sum
!
=
data
.
checksum
)
{
Serial
.
println
(
“Checksum failure”
)
;
return
false
;
}
// success!
return
true
;
}
Once the code is uploaded, you can open the serial monitor and set the baud rate to 9600. You will see the sensor start collecting the data. The sensor will start giving the correct value after 30 Seconds as it requires to some times to get warm.
Interfacing PMS5003 PM2.5 Air Quality Sensor with Arduino & LCD Dsiplay
The interfacing of PMS5003 with Arduino and LCD Display is pretty easy. You just need 4 connections. Connect PIN1 VCC of PMS5003 to Arduino 5V Pin and PIN2 GND to GND of Arduino. The UART Pin, i.e PIN4 Rx & PIN5 Tx is connected to Arduino pin 3 & 4 respectively as shown in the figure below. For 20×4 LCD Display, connect pin 1, 3, 16 to GND & 2, 15 to VCC 5V. Connect pin 4, 6, 11, 12, 13, 14 of LCD to Arduino 13, 12, 11, 10, 9, 8 Pin. Connect 10K potentiometer at pin 3 of LCD to adjust the contrast.
Source Code/Program
The source code for interfacing PM2.5 PMS5003 Air Quality Sensor with Arduino and LCD Display is given below. Simply copy the code and upload to the Arduino UNO Board.
But before that you need to add the library for PMS5003 Sensor. So simply install the following library from the library manager.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include “PMS.h”
#include “SoftwareSerial.h”
#include <LiquidCrystal.h>
LiquidCrystal
lcd
(
13
,
12
,
11
,
10
,
9
,
8
)
;
SoftwareSerial
Serial1
(
2
,
3
)
;
// RX, TX
PMS
pms
(
Serial1
)
;
PMS
:
:
DATA
data
;
void
setup
(
)
{
Serial1
.
begin
(
9600
)
;
lcd
.
begin
(
20
,
4
)
;
lcd
.
setCursor
(
0
,
0
)
;
lcd
.
(
“Warming up”
)
;
delay
(
4000
)
;
lcd
.
clear
(
)
;
}
void
loop
(
)
{
if
(
pms
.
read
(
data
)
)
{
lcd
.
clear
(
)
;
lcd
.
setCursor
(
0
,
0
)
;
lcd
.
(
“Dust Concentration”
)
;
lcd
.
setCursor
(
0
,
1
)
;
lcd
.
(
“PM1.0 :”
+
String
(
data
.
PM_AE_UG_1_0
)
+
“(ug/m3)”
)
;
lcd
.
setCursor
(
0
,
2
)
;
lcd
.
(
“PM2.5 :”
+
String
(
data
.
PM_AE_UG_2_5
)
+
“(ug/m3)”
)
;
lcd
.
setCursor
(
0
,
3
)
;
lcd
.
(
“PM10 :”
+
String
(
data
.
PM_AE_UG_10_0
)
+
“(ug/m3)”
)
;
delay
(
1000
)
;
}
}
Video Tutorial & Explanation
PM2.5 Air Quality/Dust Sensor & Arduino Interfacing tutorial with PMS5003