SKU:RB-02S185 PM2.5 传感器

来自ALSROBOT WiKi
2018年9月12日 (三) 15:38Arduino77讨论 | 贡献的版本

跳转至: 导航搜索
02S18500.png

目录

产品概述

细颗粒物又称细粒、细颗粒、PM2.5。细颗粒物指环境空气中空气动力学当量直径小于等于 2.5 微米的颗粒物。它能较长时间悬浮于空气中,其在空气中含量浓度越高,就代表空气污染越严重。PM2.5传感器是一款数字式通用颗粒物浓度传感器,可以用于获得单位体积内空气中 0.3~10 微米悬浮颗粒物个数,即颗粒物浓度,并以数字接口形式输出,同时也可输出每种粒子的质量数据。本传感器可嵌入各种与空气中悬浮颗粒物浓度相关的仪器仪表或环境改善设备,为其提供及时准确的浓度数据。

产品参数

基本参数

  1. 品名:PM2.5传感器 空气颗粒物浓度传感器
  2. 货号:RB-02S185
  3. 品牌:奥松机器人
  4. 产地:哈尔滨
  5. 固定孔:M3*2

电气性能

1.接口类型:4P发插反接口
2.信号类型:串口信号
3.指示灯:电源指示灯
4.工作电压:5V
5.工作电流:120mA
6.电源要求:功率大于1W(电流大于200mA)
7.引脚定义:

+:电源正极
-:电源负极
TX:串口数据发送端
RX:串口数据接收端
SET:休眠设置引脚,3.3V电平
SET=1 模块工作在连续采样方式下,模块在每一次采样结束后主动上传采样数据,采样响应时间为 1S
SET=0 模块进入低功耗待机模式
RST:模块复位信号,低电平复位不使用时悬空或拉高,此引脚用户可不必操作

8.连接线:4P 传感器连接线
9.检测范围:PM1.0、PM2.5、PM10、0.3μm及以上颗粒
10.工作温度:-10~60℃

02S18501.png
02S185001.jpg

使用方法

example1_Arduino

  • 主要硬件
Arduino UNO 控制器
传感器扩展板 V5.0
PM2.5 传感器
单头防插反 4P 传感器连接线
USB 数据线
  • 硬件连接
02S18502.png
  • 示例程序
#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时,开始读取
    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;
}
  • 程序效果
02S18503.png

example2_Arduino

  • 主要硬件
Arduino UNO 控制器
传感器扩展板 V5.0
PM2.5 传感器
单头防插反 4P 传感器连接线
USB 数据线
IIC1602 液晶
  • 硬件连接
02S18504.png
  • 示例程序
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);  

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

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

void setup()
{
  Serial.begin(9600);   //使用串口0
  Serial.setTimeout(1500);    //设置超时时间为1500毫秒(大于传感器传送数据周期1秒)
 
}
 
void loop()
{
  if(Serial.find(0x42)){    //检测到0x42时,开始读取
    Serial.readBytes(buf,LENG);
 
    if(buf[0] == 0x4d){
      if(checkValue(buf,LENG)){
        PM2_5Value=transmitPM2_5(buf);//count PM2.5 value of the air detector module
      }           
    } 
  }
 
  static unsigned long OledTimer=millis();  
    if (millis() - OledTimer >=1000) 
    {
      OledTimer=millis(); 

        lcd.init();                   
        lcd.backlight();
        lcd.setCursor(0, 0);         
        lcd.print("PM2.5="); 
        lcd.setCursor(6,0);
        lcd.print(PM2_5Value);
        lcd.setCursor(9,0);
        lcd.print("ug/m3");            
    }
   
}
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;
}
 
 
//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;
  }
  • 程序效果
02S18505.png

相关资料

Erweima.png
  • PM2.5传感器示例程序下载

链接:https://pan.baidu.com/s/1qCt7SBONYWYJpD4mKJPvtA 密码:g622