Build a DIY Arduino Air Quality Analyzer using Nova PM Sensor

Source and original idea via Circuit Digest.

Did you know that bad indoor air quality can cause memory problems, laziness, sore throats, skin irritation, and several other serious health concerns? According to the EPA, long-term exposure to bad indoor air can cause respiratory diseases, heart disease, and even cancer. So what can you do to ensure that your indoor air quality isn’t becoming hazardous to your health? The problem is, you don’t always know the source of the pollutant. And most of the time, you may not even feel any symptoms until later on. So to help you with that, in this post we’ll build a DIY Arduino air quality analyzer using the Nova PM sensor, so you can improve your indoor air quality.

After you are done with this project, you’ll be able to measure PM2.5 and PM10 particles’ concentration in the air.

Step 1: Gather the components

For this project, you’ll need the following:

Nova PM sensor SDS011
Arduino Nano or Arduino Nano Every
0.96’ SPI OLED display module
A couple of jumper wires

There are two important components in this project: the Nova PM sensor and OLED display module. Let’s look into their functions before we get into the technical part of the process.

Nova PM sensor (SDS011)

Nova sensor is an air quality sensor developed by Nova Fitness. It uses laser scattering to read the particle concentration through an air inlet valve, a photodiode, laser diode, and a small fan. The air goes in the air inlet, the laser illuminates the air particles which are then converted into a signal by the photodetector. These signals are amplified to get the values for PM2.5 and PM10.

See the following image for a better understanding.

Nova PM sensor specifications

⦁ Measuring range: 0.0-999.9 μg/m3
⦁ Output: PM2.5 and PM10
⦁ Max current: 100mA
⦁ Input Voltage: 4.7V to 5.3V
⦁ Response time: 1 second
⦁ Sleep current: 2mA
⦁ Serial data output frequency: 1/second
⦁ Relative error:10%
⦁ Particle diameter resolution: ≤ 0.3μm
⦁ Temperature range: -20~50°C

OLED Display Module

This project uses a Monochrome 7-pin SSD1306 0.96” OLED display. OLED is a light-emitting tool that contains a series of thin films located between two conductors. The light is produced when an electric current reaches the thin films. This particular OLED display works on three communication protocols: SPI four-wire mode, SPI 3 wire mode, and 12C mode. The following table explains the pin functions.

Pin NameOther NamesDescription
VDDVcc, 5VThe power pin of the module.
GNDGroundThe ground pin of the module.
SDAD1, MOSIData pin. Used for SPI and IIC.
SCKD0, SCL, CLKClock pin. Used for SPI and 12C.
DCA0Data command pin. Used for SPI protocol.
RESRST, RESETResets. Used during SPI.
CS Chip Select Used when more than one module is in use under SPI protocol.

OLED display module specifications

⦁ Pixel color: Blue
⦁ OLED driver IC: IC SSD1306
⦁ Visual angle: greater than 160 degree
⦁ Resolution: 128 * 64
⦁ Input voltage: 3.3V – 6V
⦁ Working temperature: -30 degree C – 70 degree C

Step 2: Connect the components

Use the circuit diagram below to connect the components:

The OLED display and the Nova sensor are powered with GND and +5V. The receiver and transmitter pins of the sensor are connected to D3 and D4 Arduino pins. Use the following table to establish connections between Arduino Nano and the OLED module.

ArduinoOLED Module
GNDGND
5VVCC
10D0
9D1
13RES
12CS
11DC

You can also use a perfboard or a breadboard to solder the components. See the images below.

Step 3: Write the code for the DIY Arduino air quality analyzer

Here we are going to use Adafruit_SSD1306, SDS011, Adafruit_GFX libraries. You can install these libraries from the Arduino IDE manager and install them. To do that, open Arduino IDE, go to sketch > include library >and then manage libraries. Now research for SDS011 and install SDS sensor library by R. Zschiegner.

In the same way, install the other two libraries by Adafruit.

After you are done installing the libraries, start with this code:

#include <SDS011.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Next, define the variables to store the values for PM2.5 and PM10.

float p10,p25;

Next, define the height and width of the OLED display. This project uses a 128 *64 OLED display. You can change the height and width according to your display.

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

With the following code, you will define the SPI.

#define OLED_MOSI   9
#define OLED_CLK   10
#define OLED_DC    11
#define OLED_CS    12
#define OLED_RESET 13

The following code will help you define the Adafruit display instance.

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

Next, add the following code to initialize the serial monitor. It will add a 9600 baud rate and initialize the sensor and OLED display.

my_sds.begin(3,4);
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC);

The following code will set up the PM2.5 and PM10 values from the sensor and print them on the serial monitor.

void loop() {
  error = my_sds.read(&p25,&p10);
  if (! error) {
    Serial.println("P2.5: "+String(p25));
    Serial.println("P10:  "+String(p10));

In the next code, you will define the text size and the text color.

display.setTextSize(2);
display.setTextColor(WHITE);

Next, use the setCurser(x,y) to define the position from where to start the text.

display.setCursor(0,15);
display.println("PM2.5");
display.setCursor(67,15);
display.println(p25);
display.setCursor(0,40);
display.println("PM10");
display.setCursor(67,40);
display.println(p10);

For the final step, use the display() to display the text on the OLED.

display.display();
display.clearDisplay();

Step 4: Test your air quality analyzer

After you are done with the code and the hardware setup, connect Arduino to your Laptop, select the port and board and upload. If everything has gone right, you should be able to see the values on the display as shown below.

Here’s the complete code for the project.

#include <SDS011.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
float p10,p25;
int error;
SDS011 my_sds;
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for SSD1306 display connected using software SPI (default case):
#define OLED_MOSI   9
#define OLED_CLK   10
#define OLED_DC    11
#define OLED_CS    12
#define OLED_RESET 13
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,
  OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
void setup() {
  my_sds.begin(3,4);
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC);
  display.clearDisplay();
  display.display();
}
void loop() {
  error = my_sds.read(&p25,&p10);
  if (! error) {
    Serial.println("P2.5: "+String(p25));
    Serial.println("P10:  "+String(p10));
    display.setTextSize(2);
    display.setTextColor(WHITE);
    display.setCursor(0,15);
    display.println("PM2.5");
    display.setCursor(67,15);
    display.println(p25);
    display.setCursor(0,40);
    display.println("PM10");
    display.setCursor(67,40);
    display.println(p10);
    display.display();
    display.clearDisplay();
  }
  delay(100);
}

Get started with your Arduino Nano or Arduino Nano Every.

We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: