亿迅智能制造网
工业4.0先进制造技术信息网站!
首页 | 制造技术 | 制造设备 | 工业物联网 | 工业材料 | 设备保养维修 | 工业编程 |
home  MfgRobots >> 亿迅智能制造网 >  >> Manufacturing Technology >> 制造工艺

基于 Arduino 与 DSM501A 传感器的空气质量监测仪

零部件与物料

零部件 数量 备注
Arduino Nano R3 1 主控板
DSM501A 粉尘传感器模块 1 检测 PM2.5 与 PM10
16×2 字符型 LCD 显示屏 1 兼容 HD44780
40mm 散热风扇套件 1 改善传感器采样准确性
LED 灯(通用) 5 指示空气质量等级
220Ω 电阻 1 LCD 背光限流
10kΩ 单圈电位器 1 调节 LCD 对比度

所需工具

软件与在线服务

项目简介

空气质量监测技术始于 20 世纪 80 年代,早期设备庞大昂贵。如今得益于现代技术,监测设备变得更精准、更快速、更小巧、更实惠。本项目采用 Samyoung DSM501A 粉尘传感器,该传感器价格极低(速卖通仅需几美元),却能同时检测 PM2.5 与 PM10 颗粒物。

传感器引脚说明

DSM501A 引脚布局如下图所示(注意:实际导线颜色可能与图示不同):

基于 Arduino 与 DSM501A 传感器的空气质量监测仪

电路连接

电路非常简单:

显示与指示逻辑

LCD 显示 PM10 浓度(单位:pcs/0.01cf)及 5 级空气质量状态:

PM10 与 PM2.5 浓度均可通过串口监视器查看。安装风扇从传感器出风口抽气,能显著改善峰值干扰,提升测量稳定性。整套装置组装在电气安装用塑料盒内。

基于 Arduino 与 DSM501A 传感器的空气质量监测仪

后续计划

未来计划测试更多低价粉尘传感器,并在后续项目中对比评测结果。

代码

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int pin2 = 3;  // PM10
int pin1 = 2;  // PM2.5
unsigned long duration1, duration2;
unsigned long starttime;
unsigned long sampletime_ms = 30000;  // 采样周期 30 秒
unsigned long lowpulseoccupancy1 = 0;
unsigned long lowpulseoccupancy2 = 0;
float ratio1 = 0, ratio2 = 0;
float concentration1 = 0, concentration2 = 0;

int wLed = A1;  // 白 - Clean
int gLed = A2;  // 绿 - Good
int yLed = A3;  // 黄 - Acceptable
int rLed = A4;  // 红 - Heavy
int bLed = A5;  // 蓝 - Hazard

void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(wLed, OUTPUT);
  pinMode(gLed, OUTPUT);
  pinMode(yLed, OUTPUT);
  pinMode(rLed, OUTPUT);
  pinMode(bLed, OUTPUT);
  starttime = millis();
  lcd.begin(16, 2);
}

void loop() {
  duration1 = pulseIn(pin1, LOW);
  duration2 = pulseIn(pin2, LOW);
  lowpulseoccupancy1 += duration1;
  lowpulseoccupancy2 += duration2;

  if ((millis() - starttime) > sampletime_ms) {
    ratio1 = lowpulseoccupancy1 / (sampletime_ms * 10.0);
    concentration1 = 1.1 * pow(ratio1, 3) - 3.8 * pow(ratio1, 2) + 520 * ratio1 + 0.62;

    ratio2 = lowpulseoccupancy2 / (sampletime_ms * 10.0);
    concentration2 = 1.1 * pow(ratio2, 3) - 3.8 * pow(ratio2, 2) + 520 * ratio2 + 0.62;

    lcd.setCursor(0, 0);
    lcd.print("PM10 ");
    lcd.setCursor(6, 0);
    lcd.print(concentration1, 3);

    Serial.print("concentration1 = ");
    Serial.print(concentration1);
    Serial.print(" pcs/0.01cf - ");
    Serial.print("concentration2 = ");
    Serial.print(concentration2);
    Serial.println(" pcs/0.01cf - ");

    // 清空第二行
    lcd.setCursor(0, 1);
    for (int i = 0; i < 16; ++i) lcd.write(' ');

    // 根据 PM10 浓度显示等级并点亮对应 LED
    if (concentration1 < 1000) {
      lcd.setCursor(4, 1); lcd.print("CLEAN");
      setLED(wLed);
    } else if (concentration1 < 10000) {
      lcd.setCursor(4, 1); lcd.print("GOOD");
      setLED(gLed);
    } else if (concentration1 < 20000) {
      lcd.setCursor(3, 1); lcd.print("ACCEPTABLE");
      setLED(yLed);
    } else if (concentration1 < 50000) {
      lcd.setCursor(4, 1); lcd.print("HEAVY");
      setLED(rLed);
    } else {
      lcd.setCursor(4, 1); lcd.print("HAZARD");
      setLED(bLed);
    }

    lowpulseoccupancy1 = 0;
    lowpulseoccupancy2 = 0;
    starttime = millis();
  }
}

void setLED(int activePin) {
  digitalWrite(wLed, activePin == wLed);
  digitalWrite(gLed, activePin == gLed);
  digitalWrite(yLed, activePin == yLed);
  digitalWrite(rLed, activePin == rLed);
  digitalWrite(bLed, activePin == bLed);
}

原理图

基于 Arduino 与 DSM501A 传感器的空气质量监测仪
完整电路接线图

制造工艺

  1. 使用 OpenSensors 监测空气质量:Arduino 与 Python 实战指南
  2. 基于 Helium 网络的太阳能供电空气质量监测站:设计与部署全指南
  3. Arduino Nano 与 MPU-6050 构建实时陀螺仪游戏
  4. 多位置温度传感器系统,助力智能家居集成
  5. K30 CO₂ 传感器:室内空气质量实时监测
  6. 自制简易红外避障传感器:IR LED + 光电二极管 + Arduino
  7. DFRobot 电容指纹传感器 (ID809) 接入 Arduino/ESP8266 完整教程
  8. 基于 Arduino、Yaler 与 IFTTT 构建 Web 化 IoT 仪表盘
  9. Arduino 简易排斥式磁悬浮:电路与 DIY 指南
  10. 高性能 Arduino 气象气球数据记录器
  11. 高精度空气质量监测仪:Sharp GP2Y1010AU0F 粉尘传感器 + Arduino Nano
  12. 先进碳基 NO₂ 传感器提升室内空气质量监测水平