Air_Quality_Monitor__PM_2.5_Temperature_and_Humidity_Sensor__SKU__SEN0233-DFRobot

SEN0233 Air Quality Monitor (PM 2.5, Formaldehyde, Temperature & Humidity Sensor)

Introduction

As the most basic part of life, air is attracting more and more attention, and the related topics like haze and PM2.5 brings hot discussions in recent years. Keeping an eye on the quality of the air we breathe is becoming quite important. This time, DFRobot introduces this multifunction air quality monitor that can detect not only the concentration of PM10, PM2.5 and PM1.0 but also the environmental temperature and humidity in real time, and then output the data via UART port. It works well with devices like Arduino and STM32.
As the particle (PM10, PM2.5 & PM1.0) concentration sensor it can use laser scattering to continuously collect and calculate the number of multi-sized suspended particles per unit of air volume, i.e. particle concentration distribution, and then convert to mass concentration. Also, it embeds in it a one-chip sensor for accurate temperature and humidity measurements.
This monitor can be inserted into various instruments related to air quality detection or environmental improvement to provide correct environmental parameters in time.

Specification

Installation Precautions

Pinout

SEN0233 Air Quality Monitor (PM 2.5, Formaldehyde, Temperature & Humidity Sensor) Board Overview
Num Label Description
PIN1 VCC + (+5V)
PIN2 GND -
PIN3 SET Set pin/TTL level @3.3V, high level or suspending is normal working status, while low level is sleeping mode.
PIN4 RXD Serial port receiving pin/TTL level @3.3V
PIN5 TXD Serial port transmitting pin/TTL level @3.3V
PIN6 RESET Module reset signal /TTL level @3.3V, low reset
PIN7 NC
PIN8 NC

Tutorial

This tutorial provides two sample codes for easily obtaining PM2.5, temperature and humidity values.

Requirements

Sample Code 1 - Arduino Leonardo

/*!
 * @file  SEN0233.ino
 * @brief Air Quality Monitor (PM 2.5, HCHO, Temperature & Humidity)
 * @n Get the module here: https://www.dfrobot.com/product-1612.html
 * @n This example is to detect formaldehyde, PM2.5, temperature and humidity in the environment.
 * @copyright  Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @license  The MIT License (MIT)
 * @author  [lijun](ju.li@dfrobot.com)
 * @version  V1.0
 * @date  2017-04-21
 */

char col;
unsigned int PMSa1 = 0, PMSa2_5 = 0, PMSa10 = 0, FMHDSa = 0, TPSa = 0, HDSa = 0, PMSb1 = 0, PMSb2_5 = 0, PMSb10 = 0, FMHDSb = 0, TPSb = 0, HDSb = 0;
unsigned int PMS1 = 0,PMS2_5 = 0,PMS10 = 0, FMHDS = 0, TPS = 0, HDS = 0, CR1 = 0, CR2 = 0;
unsigned char bufferRTT[32] = {}; //serial receive data
char tempStr[15];

void setup()
{
  // put your setup code here, to run once:
  Serial.begin(115200);

  //Select serial port(Serial1,Serial2,Serial3)
  Serial1.begin(9600);
}

void loop()
{
  // put your main code here, to run repeatedly:
  while (!Serial1.available());
  while (Serial1.available() > 0) //Check whether there is any serial data
  {
    for (int i = 0; i < 32; i++)
    {
      col = Serial1.read();
      bufferRTT[i] = (char)col;
      delay(2);
    }

    Serial1.flush();

    CR1 = (bufferRTT[30] << 8) + bufferRTT[31];
    CR2 = 0;
    for (int i = 0; i < 30; i++)
      CR2 += bufferRTT[i];
    if (CR1 == CR2)               //Check
    {
      PMSa1 = bufferRTT[10];      //Read PM1 high 8-bit data
      PMSb1 = bufferRTT[11];      //Read PM1 low 8-bit data
      PMS1 = (PMSa1 << 8) + PMSb1;   //PM1 data

      PMSa2_5 = bufferRTT[12];      //Read PM2.5 high 8-bit data
      PMSb2_5 = bufferRTT[13];      //Read PM2.5 low 8-bit data
      PMS2_5 = (PMSa2_5 << 8) + PMSb2_5;   //PM2.5 data

      PMSa10 = bufferRTT[14];      //Read PM10 high 8-bit data
      PMSb10 = bufferRTT[15];      //Read PM10 low 8-bit data
      PMS10 = (PMSa10 << 8) + PMSb10;   //PM10 data

      TPSa = bufferRTT[24];      //Read temperature high 8-bit data
      TPSb = bufferRTT[25];      //Read temperature low 8-bit data
      TPS = (TPSa << 8) + TPSb;   //Temperature data

      HDSa = bufferRTT[26];      //Read humidity high 8-bit data
      HDSb = bufferRTT[27];      //Read humidity low 8-bit data
      HDS = (HDSa << 8) + HDSb;   //Humidity data
    }
    else
    {
      PMS1 = 0;
      PMS2_5 = 0;
      PMS10 = 0;
      TPS = 0;
      HDS = 0;
    }
  }

  Serial.println("-----------------------uart--------------------------");
  Serial.print("Temp : ");
  sprintf(tempStr, "%d%d.%d", TPS / 100, (TPS / 10) % 10, TPS % 10);
  Serial.print(tempStr);
  Serial.println(" C");              //Display temperature
  Serial.print("RH   : ");
  sprintf(tempStr, "%d%d.%d", HDS / 100, (HDS / 10) % 10, HDS % 10);
  Serial.print(tempStr);            //Display humidity
  Serial.println(" %");               //%
  Serial.print("PM1.0: ");
  Serial.print(PMS1);
  Serial.println(" ug/m3"); //Display PM1.0 unit  ug/m³ 
  Serial.print("PM2.5: ");
  Serial.print(PMS2_5);
  Serial.println(" ug/m3"); //Display PM2.5 unit  ug/m³ 
  Serial.print("PM 10: ");
  Serial.print(PMS10);
  Serial.println(" ug/m3"); //Display PM 10 unit  ug/m³ 

}

Sample Code 2 - Arduino UNO (Software Serial)

Connections:

PM2.5 Sensor Adapter UNO
VCC 5V
GND GND
TX 10
RX 11
/*!
 * @file  SEN0233.ino
 * @brief Air Quality Monitor (PM 2.5, HCHO, Temperature & Humidity)
 * @n Get the module here: https://www.dfrobot.com/product-1612.html
 * @n This example is to detect formaldehyde, PM2.5, temperature and humidity in the environment.
 * @copyright  Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @license  The MIT License (MIT)
 * @author  [lijun](ju.li@dfrobot.com)
 * @version  V1.0
 * @date  2017-03-01
 */

#include <SoftwareSerial.h>

char col;
unsigned int PMSa1 = 0, PMSa2_5 = 0, PMSa10 = 0, FMHDSa = 0, TPSa = 0, HDSa = 0, PMSb1 = 0, PMSb2_5 = 0, PMSb10 = 0, FMHDSb = 0, TPSb = 0, HDSb = 0;
unsigned int PMS1 = 0,PMS2_5 = 0,PMS10 = 0, FMHDS = 0, TPS = 0, HDS = 0, CR1 = 0, CR2 = 0;
unsigned char bufferRTT[32] = {}; //serial receive data
char tempStr[15];

SoftwareSerial mySerial(10, 11); // RX, TX

void setup()
{
  Serial.begin(115200);
  mySerial.begin(9600);
}

void loop()
{

  while (!mySerial.available());
  while (mySerial.available() > 0) //Check whether there is any serial data
  {
    for (int i = 0; i < 32; i++)
    {
      col = mySerial.read();
      bufferRTT[i] = (char)col;
      delay(2);
    }

    mySerial.flush();

    CR1 = (bufferRTT[30] << 8) + bufferRTT[31];
    CR2 = 0;
    for (int i = 0; i < 30; i++)
      CR2 += bufferRTT[i];
    if (CR1 == CR2)               //Check
    {
      PMSa1 = bufferRTT[10];      //Read PM1 high 8-bit data
      PMSb1 = bufferRTT[11];      //Read PM1 low 8-bit data
      PMS1 = (PMSa1 << 8) + PMSb1;   //PM1 data

      PMSa2_5 = bufferRTT[12];      //Read PM2.5 high 8-bit data
      PMSb2_5 = bufferRTT[13];      //Read PM2.5 low 8-bit data
      PMS2_5 = (PMSa2_5 << 8) + PMSb2_5;   //PM2.5 data

      PMSa10 = bufferRTT[14];      //Read PM10 high 8-bit data
      PMSb10 = bufferRTT[15];      //Read PM10 low 8-bit data
      PMS10 = (PMSa10 << 8) + PMSb10;   //PM10 data

      TPSa = bufferRTT[24];      //Read temperature high 8-bit data
      TPSb = bufferRTT[25];      //Read temperature low 8-bit data
      TPS = (TPSa << 8) + TPSb;   //Temperature data

      HDSa = bufferRTT[26];      //Read humidity high 8-bit data
      HDSb = bufferRTT[27];      //Read humidity low 8-bit data
      HDS = (HDSa << 8) + HDSb;   //Humidity data
    }
    else
    {
      PMS1 = 0;
      PMS2_5 = 0;
      PMS10 = 0;
      TPS = 0;
      HDS = 0;
    }
  }

  Serial.println("-----------------------uart--------------------------");
  Serial.print("Temp : ");
  sprintf(tempStr, "%d%d.%d", TPS / 100, (TPS / 10) % 10, TPS % 10);
  Serial.print(tempStr);
  Serial.println(" C");              //Display temperature
  Serial.print("RH   : ");
  sprintf(tempStr, "%d%d.%d", HDS / 100, (HDS / 10) % 10, HDS % 10);
  Serial.print(tempStr);            //Display humidity
  Serial.println(" %");               //%
  Serial.print("PM1.0: ");
  Serial.print(PMS1);
  Serial.println(" ug/m3"); //Display PM1.0 unit  ug/m³ 
  Serial.print("PM2.5: ");
  Serial.print(PMS2_5);
  Serial.println(" ug/m3"); //Display PM2.5 unit  ug/m³ 
  Serial.print("PM 10: ");
  Serial.print(PMS10);
  Serial.println(" ug/m3"); //Display PM 10 unit  ug/m³ 
}

Result

Mind+ (Based on Scratch3.0) Graphical Programming (Arduino UNO Software Serial)

1.Download and install Mind+: https://www.mindplus.cc.
2.Switch to "Offline" mode.
3.Click "Extensions" and click "Board" to select Arduino UNO, and select "Software Serial" in "Function".
4.Edit a simple program as shown in the following figure.
5.After uploading the codes, open serial monitor to see output data.
Click here to see detailed tutorial.

Typical Application

Requirements

Connection Diagram

Sample Code

/*!
 * @file  SEN0233.ino
 * @brief Air Quality Monitor (PM 2.5, HCHO, Temperature & Humidity)
 * @n Get the module here: https://www.dfrobot.com/product-1612.html
 * @n This example is to detect formaldehyde, PM2.5, temperature and humidity in the environment.
 * @copyright  Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @license  The MIT License (MIT)
 * @author  [lijun](ju.li@dfrobot.com)
 * @version  V1.0
 * @date  2017-07-28
 */

#include <Wire.h>
#include <SoftwareSerial.h>
#include "DFRobot_RGBLCD1602.h"

char col;
unsigned int PMSa = 0, FMHDSa = 0, TPSa = 0, HDSa = 0, PMSb = 0, FMHDSb = 0, TPSb = 0,
             HDSb = 0, PMS = 0, TPS = 0,  HDS = 0, CR1 = 0, CR2 = 0, FMHDS = 0;
unsigned char bufferRTT[32] = {}; //serial receive data
char tempStr[15];

SoftwareSerial mySerial(10, 11); // RX, TX
/*
Change the RGBaddr value based on the hardware version
-----------------------------------------
       Moudule        | Version| RGBAddr|
-----------------------------------------
  LCD1602 Module      |  V1.0  | 0x60   |
-----------------------------------------
  LCD1602 Module      |  V1.1  | 0x6B   |
-----------------------------------------
  LCD1602 RGB Module  |  V1.0  | 0x60   |
-----------------------------------------
  LCD1602 RGB Module  |  V1.1  | 0x2D   |
-----------------------------------------
*/
DFRobot_RGBLCD1602 lcd(/*RGBAddr*/0x60 ,/*lcdCols*/16,/*lcdRows*/2);  //16 characters and 2 lines of show

void setup()
{
  Serial.begin(115200);
  mySerial.begin(9600);
  lcd.init();//Initialize LCD1602 RGB display
  lcd.setRGB(0, 255, 0); //Set the initial backlight color of the display
  lcd.setCursor(0, 0 ); //Set displaying from (0, 0)
  lcd.print("T:");//Display T:
  lcd.setCursor(9, 0 );
  lcd.print("H:");
  lcd.setCursor(0, 1 );
  lcd.print("PM2.5:");
  lcd.setCursor(9, 1 );
  lcd.print("ug/m3");
}

void loop()
{
  while (mySerial.available() > 0) //Check whether there is any serial data
  {
    for (int i = 0; i < 32; i++) //Read serial data
    {
      col = mySerial.read();
      bufferRTT[i] = (char)col;
      delay(2);
    }

    mySerial.flush();
    CR1 = (bufferRTT[30] << 8) + bufferRTT[31];
    CR2 = 0;
    for (int i = 0; i < 30; i++)
      CR2 += bufferRTT[i];
    if (CR1 == CR2)               //Check
    {
      PMSa = bufferRTT[12];      //Read PM2.5 high 8-bit data
      PMSb = bufferRTT[13];      //Read PM2.5 low 8-bit data
      PMS = (PMSa << 8) + PMSb;   //PM2.5 data
      TPSa = bufferRTT[24];      //Read temperature high 8-bit data
      TPSb = bufferRTT[25];      //Read temperature low 8-bit data
      TPS = (TPSa << 8) + TPSb;   //Temperature data
      HDSa = bufferRTT[26];      //Read humidity high 8-bit data
      HDSb = bufferRTT[27];      //Read humidity low 8-bit data
      HDS = (HDSa << 8) + HDSb;   //Humidity data
    }
    else
    {
      PMS = 0;
      FMHDS = 0;
      TPS = 0;
      HDS = 0;
    }
  }
  lcd.setCursor(2, 0 );
  sprintf(tempStr, "%d%d.%d", TPS / 100, (TPS / 10) % 10, TPS % 10); //Display temperature
  lcd.print(tempStr);
  lcd.write(0xdf);              //Display °
  lcd.print('C');               //Display C
  lcd.setCursor(11, 0 );
  sprintf(tempStr, "%d%d.%d", HDS / 100, (HDS / 10) % 10, HDS % 10); //Display humidity
  lcd.print(tempStr);
  lcd.print('%');               //Display %
  lcd.setCursor(6, 1 );
  sprintf(tempStr, "%d%d%d", PMS / 100, (PMS / 10) % 10, PMS % 10); //Display PM2.5 ones, tens, hundreds unit ug/m³ 
  lcd.print(tempStr);
}

Result

The LCD shows the current measured temperature (T), humidity (H) and PM2.5 concentration (PM2.5).

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents

DFshopping_car1.png Get Air Quality Monitor from DFRobot Store or DFRobot Distributor.

Turn to the Top