PM2.5激光粉尘传感器 V2

概述

PM2.5激光粉尘传感器是一款数字式通用颗粒物浓度传感器,可以用于获得单位体积内空气中0.3~10微米悬浮颗粒物个数,即颗粒物浓度,并以数字接口形式输出,同时也可输出每种粒子的质量数据。本传感器可嵌入各种与空气中悬浮颗粒物浓度相关的仪器仪表或环境改善设备,为其提供及时准确的浓度数据。

工作原理

本传感器采用激光散射原理。即令激光照射在空气中的悬浮颗粒物上产生散射,同时在某一特定角度收集散射光,得到散射光强随时间变化的曲线。微处理器采集数据后,通过傅立叶变换得到时域与频域间的关系,随后经过一系列复杂算法得出颗粒物的等效粒径及单位体积内不同粒径的颗粒物数量。传感器各功能部分框图如图所示: 传感器结构框图

技术规格

主要特性:

供电电源质量要求:

1、 纹波小于100mV。

2、 电源电压稳定度:4.95~5.05V。

3、 电源功率:大于1W (电流大于200mA)。

4、 上下电电压冲击小于系统电源电压的50%。

连接方式

接口说明图

传感器引脚 Arduino引脚 功能描述
Pin 1 VCC 电源正
Pin 2 GND 电源负
Pin 3 SET 模式设置
Pin 4 RXD 串口接收管脚(3.3V电平)
Pin 5 TXD 串口发送管脚(3.3V电平)
Pin 6 RESET 模块复位信号(低电平复位,不使用时拉高)
Pin 7、8 NC 悬空

注意

SET引脚:

SET=1模块工作在连续采样方式下,模块在每一次采样结束后主动上传采样数据,采样响应时间为1S。

SET=0 模块进入低功耗待机模式。

RESET引脚用户可不必操作。

通信协议

串口波特率:9600; 校验位:无; 停止位:1位; 数据包长度固定为32字节。

通讯协议

外形尺寸

外形尺寸 单位(mm)

连接Arduino

如果你有IO扩展板就可以下载代码后将PM2.5传感器转接板直插上IO扩展板,就可以用串口监视PM2.5,PM1.0和PM10的数据了。由于激光PM2.5/10灰尘/颗粒物传感器模块通讯方式是用串口实现,而DFRobot UNO R3只有一个独立的串口,所以需要先下载arduino代码之后再插上传感器,否则程序下载会出现问题。

如果没有IO扩展板就可以按照下图接线下载代码就可以啦。

:注意: :此样例只能由 arduino.cc 提供的IDE 1.6.x 及以上版本才能正常编译 |

采用软串口的使用方法

连接图

感谢论坛友人zuyang提供的原代码。 另,相比本教程使用硬件串口引脚,原代码使用软串口D10 D11 对应RX TX,可以释放硬件串口,对于连接多个串口设备有帮助。相关内容请点击这里

/*!
 * @file  SEN0177.ino
 * @brief Abstract: Read value of PM1,PM2.5 and PM10 of air quality
 * @n Modified by Cain for Arduino Hardware Serial port compatibility
 * @copyright  Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @license  The MIT License (MIT)
 * @author  Zuyang @ HUST
 * @version  V3.0
 * @date  2016-03-25
 */
#include <Arduino.h>

#define LENG 31   //0x42 + 31 bytes equal to 32 bytes
unsigned char buf[LENG];

int PM01Value=0;          //define PM1.0 value of the air detector module
int PM2_5Value=0;         //define PM2.5 value of the air detector module
int PM10Value=0;         //define PM10 value of the air detector module

void setup()
{
  Serial.begin(9600);   //使用串口0
  Serial.setTimeout(1500);    //设置超时时间为1500毫秒(大于传感器传送数据周期1秒)

}

void loop()
{
  if(Serial.find(0x42)){    //检测到0x42时,开始读取
    delay(100);
    Serial.readBytes(buf,LENG);

    if(buf[0] == 0x4d){
      if(checkValue(buf,LENG)){
        PM01Value=transmitPM01(buf); //count PM1.0 value of the air detector module
        PM2_5Value=transmitPM2_5(buf);//count PM2.5 value of the air detector module
        PM10Value=transmitPM10(buf); //count PM10 value of the air detector module
      }
    }
  }

  static unsigned long OledTimer=millis();
    if (millis() - OledTimer >=1000)
    {
      OledTimer=millis();

      Serial.print("PM1.0: ");
      Serial.print(PM01Value);
      Serial.println("  ug/m3");

      Serial.print("PM2.5: ");
      Serial.print(PM2_5Value);
      Serial.println("  ug/m3");

      Serial.print("PM1 0: ");
      Serial.print(PM10Value);
      Serial.println("  ug/m3");
      Serial.println();
    }

}

char checkValue(unsigned char *thebuf, char leng)
{
  char receiveflag=0;
  int receiveSum=0;

  for(int i=0; i<(leng-2); i++){
  receiveSum=receiveSum+thebuf[i];
  }
  receiveSum=receiveSum + 0x42;

  if(receiveSum == ((thebuf[leng-2]<<8)+thebuf[leng-1]))  //check the serial data
  {
    receiveSum = 0;
    receiveflag = 1;
  }
  return receiveflag;
}

int transmitPM01(unsigned char *thebuf)
{
  int PM01Val;
  PM01Val=((thebuf[3]<<8) + thebuf[4]); //count PM1.0 value of the air detector module
  return PM01Val;
}

//transmit PM Value to PC
int transmitPM2_5(unsigned char *thebuf)
{
  int PM2_5Val;
  PM2_5Val=((thebuf[5]<<8) + thebuf[6]);//count PM2.5 value of the air detector module
  return PM2_5Val;
}

//transmit PM Value to PC
int transmitPM10(unsigned char *thebuf)
{
  int PM10Val;
  PM10Val=((thebuf[7]<<8) + thebuf[8]); //count PM10 value of the air detector module
  return PM10Val;
}

应用样例

应用样例:穹顶之下的挣扎-DIY空气质量监测+净化器

更多

DFshopping_car1.png 购买PM2.5激光粉尘传感器