arduino/Mixly使用ZH03BPM2.5传感器
一、器材
ZH03B
资料:http://资料下载:https://pan.baidu.com/s/1R5SN2tdo6uQ4-5TypvfVdg 提取码:v6b4
https://wiki.dfrobot.com.cn/_SKU_SEN0177_PM2.5%E6%BF%80%E5%85%89%E7%B2%89%E5%B0%98%E4%BC%A0%E6%84%9F%E5%99%A8
需要注意的是上电之后需要等待10S之后才有数据
传来的数据11,12字节为PM1.0浓度,13,14字节是PM2.5浓度,15,16字节是PM10浓度
实测5,6字节也是PM1.0浓度,7,8字节也是PM2.5浓度,9,10字节也是PM10浓度
arduino uno
二、接线
ZH03B | arduino uno |
VCC | 5V |
GND | GND |
TX | D11 |
RX | D10 |
三、程序
#include <Arduino.h>
#include <SoftwareSerial.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 moduleSoftwareSerial PMSerial(10, 11); // RX, TXvoid setup()
{PMSerial.begin(9600); //使用软串口,10口等效为RX,11口等效为TXPMSerial.setTimeout(1500); //设置超时时间为1500毫秒(大于传感器传送数据周期1秒)Serial.begin(9600);
}void loop()
{if(PMSerial.find(0x42)){ //检测到0x42时,开始读取PMSerial.readBytes(buf,LENG);//值我在这里给*0.0625,也可以不乘PM01Value=transmitPM01(buf)*0.0625; //count PM1.0 value of the air detector modulePM2_5Value=transmitPM2_5(buf)*0.0625;//count PM2.5 value of the air detector modulePM10Value=transmitPM10(buf)*0.0625; //count PM10 value of the air detector module }static unsigned long OledTimer=millis(); //每隔1S打印1次PM2.5,1.0,10的值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();}}
//读取PM1.0
int transmitPM01(unsigned char *thebuf)
{int PM01Val;PM01Val=((thebuf[3]<<8) + thebuf[4]); //count PM1.0 value of the air detector modulereturn PM01Val;
}//读取PM2.5
int transmitPM2_5(unsigned char *thebuf)
{int PM2_5Val;PM2_5Val=((thebuf[5]<<8) + thebuf[6]);//count PM2.5 value of the air detector modulereturn PM2_5Val;}//读取PM10
int transmitPM10(unsigned char *thebuf)
{int PM10Val;PM10Val=((thebuf[7]<<8) + thebuf[8]); //count PM10 value of the air detector module return PM10Val;
}
四、效果
arduino/Mixly使用ZH03BPM2.5传感器相关推荐
- arduino/Mixly使用HTU21D温湿度传感器
一.器材 HTU21D 供电电压:1.5V-3.6V 温度测量范围:-40度到105度 arduino uno 二.接线 HTU21D arduino uno VCC 3.3V GND GND SC ...
- arduino/Mixly使用MAX6675热电偶传感器
一.器材 MAX6675 值得注意的是:MAX6675需要配合图中的温度探头一起使用,单独使用是不能获取温湿度的 测温范围:0度到1024度 温度分辨率:0.25度 工作电压:3.0V----5.5V ...
- arduino/Mixly使用MH-Z19B二氧化碳传感器
一.器材 MH-Z19B 一共有三种输出方式:PWM输出,模拟输出,TTL串口输出,在这里我使用的是模拟输出 arduino uno 二.接线 MH-Z19B arduino uno VCC 5V G ...
- Arduino Mixly入门到精通教程
目录 1.介绍 2.实验器材和相关资料下载链接 3. Uno Plus 开发板和米思齐软件 第1小节 简单介绍 Uno Plus 开发板 第2小节 Uno Plus 开发板的驱动安装方法 第3小节 ...
- Android手机HC-05蓝牙连接Arduino nano获取DHT-11温湿度传感器数据
如果您觉得本文对您有用,希望您点赞,收藏并且把它分享出去,不明白的可以在评论区留言,我会一一解答,感谢您的支持!! 目标 Android手机HC-05蓝牙连接Arduino nano获取DHT-11温 ...
- Arduino KY-024线性磁力霍尔传感器
Arduino KY-024线性磁力霍尔传感器 KY-024模块介绍 主要芯片:LM393.3144霍尔传感器磁感应探头 工作电压:直流5伏 特点: 1.具有信号输出指示 2.带安装孔,方便固定安装 ...
- Arduino笔记实验(初级阶段)—火焰传感器+有源蜂鸣器实验
Arduino笔记实验(初级阶段)-火焰传感器+有源蜂鸣器实验 文章目录 Arduino笔记实验(初级阶段)-火焰传感器+有源蜂鸣器实验 前言 一.电路图 二.火焰传感器(4引脚)-有源蜂鸣器 代码 ...
- Arduino Uno 使用TCS3200D颜色传感器 分辨颜色
欢迎关注「凌顺实验室」微信公众号 TCS3200颜色传感器 实验效果 把色纸放在传感器2CM左右高的地方, 可以检测到该物体的RGB值, 然后我们通过画板可以检验出颜色是否正确 在实际环境中,自然光, ...
- 使用Arduino开发板和颜色传感器TCS230实现颜色感应
在本篇文章中,我们将学习如何使用Arduino开发板和颜色传感器TCS230 / TCS3200来检测颜色. 色彩传感器TCS230的工作原理 TCS230通过内部的8 x 8光电二极管阵列感应彩色光 ...
最新文章
- 智源成立面向可持续发展的人工智能智库并发布公益研究计划
- Building Shops dp 预处理距离
- java3d box 坐标,3d transform的坐标空间及位置
- python中的def语句输出1000以内的回文_各种方法测试回文的性能[Python]
- 更新显示当前歌曲的名称 winform 0130
- 层次聚类 matlab代码_聚类算法解析一
- antd option宽度自适应_前端基础:自适应布局之rem布局基础
- 使用javamail通过代理发送邮件
- 查找所有的两个字姓名,中间加个空格(强迫症的福音)
- 怎么报名mysql证书_报考oraclemysql认证考试的流程有哪些
- 郑传华:微商快速赚钱108招
- 找出水王 java_寻找水王1
- C盘清理方法——基于spacesniffer软件和PatchCleaner软件
- Swing Copters摇摇欲坠游戏再次风靡全球,再次虐心,摔手机
- android 自定义字体 ttf,Android APP支持自定义字体
- 三星公佈Bixby2.0升級後比蘋果更酷
- MLY -- 5.your development and test sets
- css 的 calc() 方法
- Android兴趣选择功能的实现
- SPSS分析技术:时间序列分析的ARIMA模型;考虑各种促销因素的服装销售额预测