Air Surfer
组件和用品
![]() |
| × | 1 | |||
| × | 1 | ||||
| × | 1 | ||||
![]() |
| × | 1 | |||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 |
应用和在线服务
![]() |
|
关于这个项目
作为一名土木工程师,我非常清楚通风系统在家里应该如何工作。因此,为了测量我公寓的空气质量,我购买了一台 CO2 监测器,我非常喜欢它,因为它不仅可以显示 CO2 水平,还可以显示室温。
然而,这对我来说还不够。我想测量更多的参数,所以我正在寻找合适的设备。我发现有些贵得离谱,所以我决定自己做。
那时我已经有为一个泵站的arduino控制器编程的经验,电磁阀控制不同的管道分支。
我在纸上做了一个项目,然后订购了必要的工具和传感器。
基地
我希望它有一个最小 10 英寸的大屏幕,但它会很快清空我的口袋。我决定现实一点,选择了带有 tft 3.2 420x380 显示屏的 Arduino Mega 2560 R3。这种设置需要最少的布线,因为显示器直接连接到 arduino 板。
不幸的是,我从速卖通订购的显示器太便宜了,效果不佳。有白色的小点随着时间和倒色出现。我尝试了不同的库和不同的控制器,但没有帮助。所以我在代码中调整了颜色,并在中午 12 点和凌晨 12 点添加了屏幕刷新。




传感器
该项目最昂贵的部分是 mh-z19 二氧化碳传感器。在提供可靠的测量和自动校准功能的同时,它在其他 CO2 传感器中相对便宜。


虽然其他模块相对容易安装,但该传感器的数据表中没有太多信息,因此我在论坛上查找代码并将所有信息组合在一起。结果,现在一切都完美无缺,甚至比以前的传感器更好。
然而,它需要 24 小时进行自我校准,所以最初它的读数不一致。自动校准很简单。当我离开我的公寓时,没有人消耗氧气,所以二氧化碳水平下降到室外水平,即 400 ppm。如果读数低于此数字,则传感器校准。
它可以通过UART和PWM进行通信。我选择第一个是因为我认为它更可靠。

然后我使用 SI7021 温度和湿度传感器进行室内监控,该传感器使用 I2C 协议并连接到 SDA 和 SCL 引脚。不贵,工业精度高。我喜欢它,因为我根本没有遇到任何麻烦。


对于室外温度,我使用封装在不锈钢胶囊中的 ds18b20。廉价而准确的读数。但是,它需要 4,7k 欧姆电阻,所以不要忘记它。通讯是通过1-wire。




当时我购买了使用 I2C 的 DS 1307 RTC 模块。


然后是 3 个 LED 显示 CO2 水平。 400-800ppm 为绿色 LED,800-1200ppm 为橙色 LED,1200ppm 及以上为红色 LED。
此外,还有 3 个带 LED 的不锈钢按钮。左边的是小时调整。中间一个是分钟,右边一个是改变文字颜色。
此外,我连接了一个光敏电阻来调节 LED 的亮度。我不想让它们在晚上太亮。






电源
对于电源,我在底部钻了一个孔并在那里放置了一个直流连接器:

问题是我没有任何合适的电源。我只有 19v 和 15v 电源适配器,而 Arduino 的推荐电压是 7-12v。但是,我有一堆 LM2696 DC-DC 可调稳压器。

我把它放在盒子里面并调整到 7 伏。我发现我的 Arduino 在 12 伏以下很快升温,所以我选择了推荐的最小值。因此,现在它可以由各种电源供电。

对于室外温度传感器,我使用了飞行员连接器和电话线。



方框
这对我来说是主要问题,因为我没有 3D 打印机。起初我试图用聚合物粘土制作它,但它没有很好地保持它的形状。另外,我在烤箱里烧了它。



第二次尝试是使用 6 毫米胶合板。大部分都很好,但很难切割。我不得不使用电锯和dremel工具。








最后一个也是最成功的一个来自 3 毫米胶合板(很难找到),我可以在没有电气设备的情况下切割,只使用开箱刀和一些砂纸。涂上丙烯颜料,结果看起来好多了。












成本
- Arduino Mega 2560 R3 - 8,27 美元(480 卢布)
- 显示 TFT 3.2 480x320 - 8 美元(400 卢布)
- RTC DS1307 模块 - 0.55 美元(32 卢布)
- CO2 mh-z19 传感器 - 20 美元(1160 卢布)
- 温湿度传感器 Si7021 - 2$(118Rub)
- 胶囊中的温度传感器 DS18b20 - 1,14 美元(66 卢布)
- 光敏电阻 - 1 美元/50 个 (65Rub)
- LED - 0.67 美元/100 个 (39Rub)
- 不锈钢按钮 - 5,07 美元/3 个 (294Rub)
- GX12-3 针航空插头(套装) - 1,17$ (68Rub)
- 直流连接器 1,25 美元/10 个 (73Rub)
- LM2596 DC-DC 可调稳压器 - 0.69 美元(40 卢布)
- 电源适配器 12v - 2,14 美元(120 卢布)
- 电线 - 1,78 美元(100 卢布)
- 胶合板 3 毫米 - 1,78 美元(100 卢布)
总计 55,51 美元(3155 卢布)
代码
- 空中冲浪者代码
空中冲浪者代码Arduino
#include#include "RTClib.h"//#include #include #include #include #include #include #include #define ONE_WIRE_BUS 9#define GREENLED 5#define YELLOWLED 7#define REDLED 8#define BUTTONLED 11OneWire oneWire(ONE_WIRE_BUS);DallasTemperature sensor(&oneWire);UTFT myGLCD(CTE32HR, 38, 39, 40, 41); HTU21D myHumidity;RTC_DS1307 rtc;外部 uint8_t Ubuntu[];字节 cmd[9] ={0xFF,0x01,0x86,0x00,0x00,0x00,0x00,0x00,0x79};无符号字符响应[9];无符号整数 ppm;无符号长时间;整数光电池读数;整数小时;整数分钟;浮动 humd;浮动温度;整数 tcolor;整数 Z; //LED 亮度布尔值 Reset =false; // 用于重置显示;无效灯(无效){ //CO2if (ppm<800){ myGLCD.setColor(255,140,255); //绿色 myGLCD.fillCircle(450, 87, 12);模拟写入(绿色,Z);模拟写入(黄色,0);模拟写入(红色LED,0); } if (ppm>800 &ppm<1200) { myGLCD.setColor(70,70,255); //黄色 myGLCD.fillCircle(450, 87, 12);模拟写入(绿色,0);模拟写入(黄色,Z);模拟写入(红色LED,0);}如果(ppm> 1200){ myGLCD.setColor(VGA_AQUA); myGLCD.fillCircle(450, 87, 12);模拟写入(绿色,0);模拟写入(黄色,0);模拟写入(红色,Z); } //嗡嗡声 if (humd>30 &humd<50) { myGLCD.setColor(255,140,255); //绿色 myGLCD.fillCircle(450, 149, 12); } if (humd>20 &humd<30) { myGLCD.setColor(70,70,255); //黄色 myGLCD.fillCircle(450, 149, 12); } if (humd<20) { myGLCD.setColor(70,70,255); //黄色 myGLCD.fillCircle(450, 149, 12); } if (humd>50 &humd<60) { myGLCD.setColor(70,70,255); //黄色 myGLCD.fillCircle(450, 149, 12); } if (humd>60) { myGLCD.setColor(VGA_AQUA); myGLCD.fillCircle(450, 149, 12); } //Temp ins if (temp> 20 &temp<27) { myGLCD.setColor(255,140,255); //绿色 myGLCD.fillCircle(450, 213, 12); } else {myGLCD.setColor(70,70,255); //YellowmyGLCD.fillCircle(450, 213, 12); } //Tempouts if (sensors.getTempCByIndex(0)<10) {myGLCD.setColor(70,70,255); //YellowmyGLCD.fillCircle(450, 278, 12);} else { myGLCD.setColor(255,140,255); //green myGLCD.fillCircle(450, 278, 12);}}void drawmain(void) {myGLCD.setFont(Ubuntu);if (tcolor==0) myGLCD.setColor(VGA_BLACK);if (tcolor==1) myGLCD.setColor(VGA_SILVER);if (tcolor==2) myGLCD.setColor(250,10,250);if (tcolor==3) myGLCD.setColor(200,100,200);if (tcolor==4) myGLCD.setColor(100,200,200);if (tcolor==5) myGLCD.setColor(10,200,200);if (tcolor==6) myGLCD.setColor(200,200,100);if (tcolor==7) myGLCD.setColor(250,250,10);if (tcolor==8) myGLCD.setColor(10,10,250);if (tcolor==9) myGLCD.setColor(10,250,10);if (tcolor==10) myGLCD.setColor(250,10,10);if (tcolor==11) myGLCD.setColor(VGA_TEAL);如果(tcolor==12)myGLCD.setColor(VGA_AQUA);现在日期时间 =rtc.now(); // Timeif (now.hour()<10) { myGLCD.print("0", 190, 7);myGLCD.printNumI(now.hour(), 215, 7); } else {myGLCD.printNumI(now.hour(), 190, 7); } myGLCD.print(":", 240, 5); if (now.minute()<10) { myGLCD.print("0", 265, 7);myGLCD.printNumI(now.minute(), 290, 7); } else { myGLCD.printNumI(now.minute(), 265, 7); }//myGLCD.setColor(VGA_BLACK);myGLCD.print("CO2", 18, 74); if (ppm> 999){ myGLCD.printNumI(ppm, 250, 74);}else{myGLCD.print(" ", 250, 74);myGLCD.printNumI(ppm, 275, 74);}myGLCD.print(" ppm", 348, 74);myGLCD.print("Humidity", 18, 136);myGLCD.printNumI(humd, 343, 136); //humdmyGLCD.print("%", 398, 136);myGLCD.print("Temp(in)", 18, 200);if (temp> =0) { if (temp<10) {myGLCD.print( " ", 275, 200);myGLCD.print("+", 300, 200); //tempmyGLCD.printNumF(temp,1, 325, 200);}else{ myGLCD.print("+", 275, 200); //tempmyGLCD.printNumF(temp,1, 300, 200);}}if (temp<0){ if (temp> -10) { myGLCD.print(" ", 275, 200);myGLCD.printNumF(temp, 1, 300, 200);}else{ myGLCD.printNumF(temp,1, 275, 200);}}myGLCD.print("C", 398, 200);myGLCD.print("Temp(out)", 18 , 265);if (sensors.getTempCByIndex(0)<-100) { myGLCD.print("Empty", 300, 265);}else{if (sensors.getTempCByIndex(0)>=0) { if (sensors. getTempCByIndex(0)<10) {myGLCD.print(" ", 275, 200);myGLCD.print("+", 300, 265);myGLCD.printNumF(sensors.getTempCByIndex(0),1, 325, 265);}else{ myGLCD.print("+", 275, 265);myGLCD.printNumF(sensors.getTempCByIndex(0),1, 300, 265);}}if (sensors.getTempCByIndex(0)<0){ if (sensors.getTempCByIndex(0)>-10) { myGLCD.print(" ", 275, 200);myGLCD.printNumF(sensors.getTempCByIndex(0),1, 300, 265);}else{ myGLCD.printNumF(sensors .getTempCByIndex(0),1, 275, 265);}}myGLCD.print("C", 398, 265);}} void dateandtime(void) { DateTime now =rtc.now();hourupg=now.hour ();minupg=now.minute(); //时间调整 if (digitalRead(3) ==LOW) { if (minupg==59) { minupg=0; } else { minupg=minupg+1; rtc.adjust(DateTime(0,0,0,hourupg,minupg,0)); } if (digitalRead(2) ==LOW) { if(hourupg==23) { hourupg=0; } else { hourupg=hourupg+1; rtc.adjust(DateTime(0,0,0,hourupg,minupg,0)); }}void co2(void) { Serial3.write(cmd, 9); memset(响应, 0, 9); Serial3.readBytes(响应,9);国际我;字节CRC =0; for (i =1; i <8; i++) crc+=response[i]; CRC =255 - CRC; CRC++; if ( !(response[0] ==0xFF &&response[1] ==0x86 &&response[8] ==crc) ) { } else { unsigned int responseHigh =(unsigned int) response[2]; unsigned int responseLow =(unsigned int) response[3]; ppm =(256*responseHigh) + responseLow; }}void th(void) { humd =myHumidity.readHumidity(); temp =myHumidity.readTemperature();传感器.requestTemperatures(); // 发送获取温度读数的命令}void photosensor(void) { photocellReading =analogRead(12); if (photocellReading <150) { // Serial.println(" - Dark");模拟写入(按钮LED,5); Z=25; } else if (photocellReading <300) { // Serial.println(" - Dim");模拟写入(按钮LED,50); Z=80; } else if (photocellReading <700) { // Serial.println(" - Light");模拟写入(按钮LED,100); Z=120; } else if (photocellReading <900) { // Serial.println(" - Bright");模拟写入(按钮LED,150); Z=150; } else { // Serial.println(" - 非常亮");模拟写入(按钮LED,200); Z=200; }// Serial.print(photocellReading);}void screenreset(void) { if(((hourupg==0 &&minupg==0) || (hourupg==12 &&minupg==0)) &&Reset==false ) {myGLCD.clrScr();myGLCD.fillScr(VGA_WHITE); //由于我的 displaymyGLCD.setBackColor(VGA_WHITE) 上的颜色反转; //由于我的 displayReset=true 上的颜色反转;}if((hourupg==0 || hourupg==12)&&minupg>0) { Reset=false; }}void setup(void) {myGLCD.InitLCD();myGLCD.clrScr();myGLCD.fillScr(VGA_WHITE); //由于我的 displaymyGLCD.setBackColor(VGA_WHITE) 上的颜色反转; //由于我的 displaySerial3.begin(9600);//Serial.begin(9600);传感器开始(); myHumidity.begin(); tcolor=0;rtc.begin();pinMode(GREENLED, OUTPUT);pinMode(YELLOWLED, OUTPUT);pinMode(REDLED, OUTPUT);pinMode(BUTTONLED, OUTPUT);pinMode(2, INPUT_PULLUP);pinMode(3, INPUT_PULLUP) );pinMode(4, INPUT_PULLUP);Z=0;}void loop(void) {co2();光电传感器();日期和时间();th(); if (digitalRead(4) ==LOW){ tcolor=tcolor+1; }if (tcolor>=13) tcolor=0; drawmain();lamps();screenreset();}
示意图

制造工艺