éå§ãã
ãã®ãããžã§ã¯ãã®ã¢ã€ãã¢ã¯ãã¢ãªã«å¯ŸããDYIã®ç±æã®äžã§ã MQ-135空æ°è³ªã»ã³ãµãŒãè³Œå ¥ãããæ°å¹Žåã«çãŸããŸããã ä»æ§ã«ãããšããã®ã»ã³ãµãŒã¯ç©ºæ°äžã®NH3ãââNOxãã¢ã«ã³ãŒã«ãã¬ãœãªã³ãç ãCO2ãªã©ã®ç©è³ªã®ååšã«åå¿ããã¢ããã°åºåã§ç©ºæ°ã®è³ªãæšå®ããŸã[ã¯ãããã¥ãŒãã³ã°æµæãšãã£ãªãã¬ãŒã·ã§ã³æ¹æ³ãããããšãç¥ã£ãŠããŸãããè€éããã]ã
ãã¹ãã§ã¯ãã»ã³ãµãŒãããããçš®é¡ã®æ害ãªãèããååç©ã«å®å šã«åå¿ããåºåã¬ãã«ãããªãæ¥æ¿ã«å€åããããšã瀺ãããŠããŸãã ç¶æ³ã¯ãç®ã«èŠããªãæµãã€ãŸãäºé žåççŽ CO2ã®å®çŸ©ã«ããæªåããŸããã ãã®äºé žåç©ã®å®³ãšæçœãªéåšã«ã€ããŠå€ãã®ããšãèšãããŠããŸãããç¹°ãè¿ãã¯ããŸããã
ãããã£ãŠãç§ã«ãšã£ãŠãMQ-135ã»ã³ãµãŒã¯åœ¹ã«ç«ããªãããšãå€æããŸããããªããªãã人ãæ··éããŠããéšå±ãšæ°é®®ãªç©ºæ°ã®ç©ºæ°ã®è³ªã®å€§ããªéãã«ãæ°ä»ããªããããã§ãã ããããåŒã³åºãã¯ãã§ã«åãå ¥ããããŠããã®ã§ãæ°åã®ã€ã¿ã¬ãŒã·ã§ã³ã®åŸã MH-Z19 IRã»ã³ãµãŒãåããOpenWindAirããŒãã®æåŸã®ïŒçŸåšã®ïŒããŒãžã§ã³ãèªçããŸãã [å®ç§ã§ã¯ãªããã¯ã]ã çµæã®ããŒããŠã§ã¢ãšãã®ããŒããŠã§ã¢æ©èœã®è©³çŽ°ã«ã€ããŠã¯ãèšäºESPã®ããŒã¿åéã·ã¹ãã ãã芧ãã ããã ããŒãI
äœå® ã®å»ºç©ã®äºé žåççŽ ã®ã¬ãã«ã枬å®ããã¿ã¹ã¯ã§ã¯ãã»ã³ãµãŒã¯çæ³çã§æé©ãªãœãªã¥ãŒã·ã§ã³ã§ããããšãå€æããŸããïŒé éä»ãã¢ãªã§1200ã«ãŒãã«ïŒã
Blynk-éãã¯ã©ãŠããé»è©±ã®æ¥ç¶ãæ¯æŽ
Blynkãã©ãããã©ãŒã ã«ã€ããŠã¯ãããšãã°ããã§æ¢ã«å€ãã®è¯ãããšãèšãããŠããŸã ã ãã©ãããã©ãŒã ã®æ©èœã¯ããã®ææ ®æ·±ããšäœ¿ããããã«é©ãã°ããã§ãã ãã®ãããESP8266ã®éçºç°å¢ãéžæããŠããã°ã©ã ãäœæãããšããæ¥ããšããéžæã¯ããã«Arduino IDEãšBlynkã©ã€ãã©ãªã«å§ããããŸããã
ãã¹ãã¹ã±ããBlynkSimpleEsp8266ãå®è¡ããŠããåé¡ã¯çºçããŸããã§ããã ãã ããæ©èœãããè€éã«ãªããæ©èœã匷åãããã«ã€ããŠãããã€ãã®å°é£ã«çŽé¢ããå¿ èŠããããŸãããããã«ã€ããŠè©³ãã説æããããšæããŸãã
ãœãããŠã§ã¢ã¢ãŒããã¯ãã£
Arduino IDEç°å¢ã§ESP8266çšã®ãœãããŠã§ã¢ãéçºããäž»ãªå©ç¹ã¯ã1ã€ã®ã¹ã±ããã§ãŸã£ããç°ãªãã©ã€ãã©ãªãçµã¿åãããããšãã§ããã»ãšãã©äœãæããªãããšã§ãã
TKãéçºãããåã¯ãè«æãçå®ããã次ã®ç¹ãå«ãŸããŠããŸããã
1. CO2ã»ã³ãµãŒïŒMH-Z19ïŒãäžå®ã®ééã§èªã¿åãã3ã€ã®ïŒç·ãé»ãèµ€ïŒLEDã䜿çšããŠçµæã衚瀺ããå¿ èŠããããŸãã å¶éã¯ã GOST 30494-2011 ïŒäœå® ããã³å ¬å ±ã®å»ºç©ãéšå±ã®åŸ®æ°åãã©ã¡ãŒã¿ïŒãã»ãŒèæ ®ããŠéžæãããŸãããæ倧900 PPM-ç·ã901ã1400 PPM- é»è² ã1401 PPM- èµ€ãè¶ ããŠããŸãã ãŸããããŒãé³ã®ãããå€ã1100 PPMã«èšå®ãããŠããããŒãé³ããããŸãããBlynkã§å®å šã«èšå®ãŸãã¯ç¡å¹åã§ããŸãã ãããã°äžã«ãMH-Z19ãå®éã«æž¬å®ããã代ããã«ãã°ãªããããŠæ倧å€ïŒèšå®ãããå¶éã«å¿ããŠïŒ1000ã2000ã3000ãŸãã¯5000 PPMïŒãäžããããšãããããšãå€æããŸããã ããã«ãããçµæã®åŠçãããè€éã«ãªãããŠãŒã¶ãŒãžã®èª€ã£ãã¡ãã»ãŒãžã«ã€ãªããå¯èœæ§ãããããŠãŒã¶ãŒã®ç¥çµãä¿è·ããå¿ èŠããããŸãã ãŸãã誀ã£ãŠæž¬å®ããã2000 PPMïŒå± äœåºã®éçå€ïŒãããŠãŒã¶ãŒã座ã£ãŠã»ã³ãµãŒã«åžã蟌ãã ãšãã®ç¶æ³ããåºå¥ããããã®çµ¶å¯Ÿçã«æ£ããïŒè€æ°ã®æž¬å®ãé€ãïŒæ¹æ³ã¯ãããŸããã ãã®åé¡ãã«ã¢ãã©ãŒãžã¥ããããã«2ã€ã®æ段ãåãããŸããïŒæž¬å®éçã¯2000 PPMã«èšå®ããïŒããã€ã¹ã¯äœå® ã®æ·å°å ã§äœ¿çšããã1400ãè¶ ãããã®ã¯ãã¹ãŠã¬ãããŸãŒã³ã§ãããšæ³å®ãããŸãïŒãæåŸã®10ã®æž¬å®çµæã®å¹³åãè¿œå ãããŸããã ãã®çµæãåäžã®èª€æ€ç¥ïŒ2000 PPMïŒã§ã¯ãå¹³åã°ã©ãã«å€§ããªãµãŒãžã¯çºçããŸããã ãã ããå¿ èŠã«å¿ããŠãBlynkã䜿çšããŠã»ã³ãµãŒã®æž¬å®å¶éã調æŽããå®éã®ïŒå¹³åCO2å€ã§ã¯ãªãïŒã確èªã§ããŸãã
2. Adafruit DHTã»ã³ãµãŒã©ã€ãã©ãªã䜿çšããŠã枩床/湿床ã»ã³ãµãŒïŒ AM2302 ïŒãæäœããŸããã 2ã€ã®å°ããªå€æŽãè¡ãããŸããïŒAM2302ã®åèªã¿åãã®è¿œå ïŒæåã«èªã¿åãããªãå ŽåããããŸãïŒããã³æž©åºŠãšæ¹¿åºŠã®å€ã®è£æ£ä¿æ°ãå°å ¥ãããŸããã å èµã»ã³ãµãŒã䜿çšããå Žåãå€éšã»ã³ãµãŒïŒãžã£ã³ããŒã§éžæïŒã䜿çšããå Žåãããã€ã¹å éšã®ç©ºæ°ã¯å€éšãã15ïŒ ã也ç¥ãããå€éšãã2°CïŒ1°FïŒæãããªãããšãå®éšçã«ç¢ºç«ãããŠããŸã-枬å®çµæãä¿®æ£ããªãã§ãã ããç¡å¹ã«ããããšãã§ããŸãã
3.ãŠãŒã¶ãŒã¯ãè¿œå ã®ãœãããŠã§ã¢ããã©ãã·ã¥ãªãã§ãããã€ã¹ãæ§æïŒWiFiãžã®æ¥ç¶ãèªèšŒããŒã¯ã³ã®æå®ãªã©ïŒã§ããå¿ èŠããããŸãã æãæé©ãªãœãªã¥ãŒã·ã§ã³ã¯ã WiFiManagerã©ã€ãã©ãªã䜿çšããããšã§ãã ãããã«ãããESPãã¢ã¯ã»ã¹ãã€ã³ãã¢ãŒãã«ãªãã CaptiveããŒã¿ã«ãä»ããŠWiFièšå®ããã®ä»ã®ãã©ã¡ãŒã¿ãŒãUSBãã©ãã·ã¥ãã©ã€ãã«ä¿åã§ããŸãã
å°æ¥çã«ã¯ãèµ·åæã«ãã©ã€ãã©ãªã¯ä¿åãããWiFiãã€ã³ããžã®æ¥ç¶ãè©Šã¿ãé害ãçºçããå Žåãã¢ã¯ã»ã¹ãã€ã³ããšãã£ããã£ãããŒã¿ã«ã¢ãŒãã«æ»ããŸãã ãŸãããŠãŒã¶ãŒãçªç¶Blynkã䜿çšããããªãå ŽåããŸãã¯WiFiã«ãŒã¿ãŒããªãå ŽåãOpenWindAirã¯èµ·åãããAPã¢ãŒãã§ã®ã¿èµ·åããã¿ã€ã ã¢ãŠãã§åèµ·åããŸãã
ãã®çµ¶æçãªç¶æ³ããæãåºãæ¹æ³ã¯ãBlynkãŸãã¯MQTTãµãŒããŒã«æ¥ç¶ããããã®ãŒã以å€ã®èšå®ããŸã ããå Žåãéå§æã«æ¥ç¶ãšåèµ·åãè©Šã¿ãŸãã
if (!wifiManager.autoConnect("OpenWind - tap to config")){ if (mqtt_server[0] != '\0' || blynk_token[0] != '\0'){ Serial.println("Failed to go online for Blynk and MQTT, restarting.."); ESP.restart(); } else{ Serial.println("Failed to go online, offline mode activated"); online = false; }
4. Blynkã«ã¯ã€ã³ã¿ãŒãããæ¥ç¶ãå¿ èŠã§ãïŒãµãŒããŒãããŒã«ã«ã§ãªãå ŽåïŒããããã£ãŠãWiFiæ¥ç¶ã®å¯çšæ§ãå¶åŸ¡ããå¿ èŠããããŸãã çŸæç¹ã§WiFiManagerã©ã€ãã©ãªã¯WiFiã«åæ¥ç¶ã§ãããã¢ããŒãå ã®ã©ã€ãããç¹æ» ãããŠã«ãŒã¿ãŒãåèµ·åããå Žåãåèµ·åããã ãã§ESP8266ãWiFiã«åŸ©å ã§ããŸãã ãã®ããã60ç§é£ç¶ããŠæ¥ç¶ããªããšããã€ã¹ãåèµ·åããåçŽãªã¿ã€ããŒãè¿œå ããå¿ èŠããããŸããã
if (WiFi.status() != WL_CONNECTED && online){ if (!wifilost_flag){ wifilost_timer_start = uptime; wifilost_flag = true; } if (((uptime - wifilost_timer_start) > wifilost_timer_max) && wifilost_flag){ Serial.print("\n\rWiFi connection lost, restarting.."); wifilost_flag = false; ESP.restart(); } }
5. Blynkã䜿çšãã代ããã«ããŠãŒã¶ãŒã¯MQTTãããã³ã«ãä»ããŠèšŒèšãPeople's MonitoringãµãŒããŒãŸãã¯ä»ã®åæ§ã®ãµãŒãã¹ã«éä¿¡ããããšãéžæã§ããŸãã ãããã®ç®çã®ããã«ã PubSubClientã©ã€ãã©ãªãéžæãããŸããããã®ã©ã€ãã©ãªã¯ãæãç解ããããCèšèªã§æžãããŠãããæ確ãªäŸãæã£ãŠããå¯äžã®ïŒArduino IDEãã£ã¬ã¯ããªã«ãããã®ããïŒã§ãã
6.é »ç¹ã§ã¯ãªããããã»ã©è€éã§ã¯ãããŸãããïŒç¹ã«çµã¿èŸŒã¿CP2102ãäœ¿çš ïŒãããã€ã¹ããã©ãã·ã¥ããŸããããã®ããã»ã¹ãå¯èœãªéãåçŽåããããšæã£ãŠããŸãã ArduinoOTAã©ã€ãã©ãªã䜿çšãããšãæ°ãããã€ããªãç°¡åã«ããŠã³ããŒãããŠãã©ãã·ã¥ã§ããŸãã OTAã¯ãããã€ã¹ã®ãã¿ã³ãŸãã¯é»è©±ãä»ããŠãªã¢ãŒãã§ã¢ã¯ãã£ãåã§ããŸãã ãã ããããã€ãã®é©ãããããŸããããç°ãªããã¡ã€ã«ã·ã¹ãã ãµã€ãºïŒSPIFFSïŒã®ESP8266-12Eã¢ãžã¥ãŒã«ãè³Œå ¥ããããšãããããŸããã
Flash
ESP8266-12Eã®å€éšçã«åºå¥ã§ããªãã¢ãžã¥ãŒã«ã¯ããµã€ãºã1 MBãŸãã¯3 MBã®ãã¡ã€ã«ã·ã¹ãã ãæã€ããšãã§ããç°ãªããã¡ãŒã ãŠã§ã¢ïŒArduino IDEã®ãã«ããªãã·ã§ã³ïŒãå¿ èŠã§ãã ãããã£ãŠãèµ·ããããåé¡ãåé¿ããããã«ãããŒãæã«å®éã®ã¡ã¢ãªãµã€ãºã確èªããOTAã¢ããã°ã¬ãŒãæã«ãµãŒããŒäžã®é©åãªãã€ããªãèŠæ±ããå¿ èŠããããŸãïŒãŸã å®è¡ãããŠããŸããïŒã ãŸãã¯ãå°ãç°¡åãªæ¹æ³ã§1 MBã®å°ããå ¬ç§°å€ã§SPIFFSã®ãã¹ãŠã®ãã¡ãŒã ãŠã§ã¢ãåéã§ããŸãããããã¯ã倧éã®ã¡ã¢ãªãæèŒããESP8266-12Eã§åäœããããã§ãã
ãã®ãããªãã§ãã¯ã®ããã«ãSDKã«ã¯IDEã§å®éã®ã¡ã¢ãªãšéžæãããã¡ã¢ãªã®ãµã€ãºã決å®ã§ãã䟿å©ãªæ©èœããããŸãã
String realSize = String(ESP.getFlashChipRealSize()); String ideSize = String(ESP.getFlashChipSize()); bool flashCorrectlyConfigured = realSize.equals(ideSize); if(flashCorrectlyConfigured){ Serial.println("flash correctly configured, SPIFFS starts, IDE size: " + ideSize + ", match real size: " + realSize); } else{ Serial.println("flash incorrectly configured, SPIFFS cannot start, IDE size: " + ideSize + ", real size: " + realSize); }
7.ç°ãªããœãããŠã§ã¢ããŒãžã§ã³ã§æ··ä¹±ããªãããã«ããŸãããããçžäºã«åºå¥ããªãããã«ãArduino IDEã®arduino-1.8.5 \ hardware \ platform.txtãã¡ã€ã«ããããã«æžãæããŠãã³ã³ãã€ã«äžã«batãã¡ã€ã«ãèµ·åããçŸåšã®ã¹ã±ããã®ã³ããŒãäœæããŸãçµæã®ãã€ããªãããã³ããŒãžã§ã³çªå·ãèªåçã«ã€ã³ã¯ãªã¡ã³ãããŸãã
recipe.hooks.sketch.prebuild.0.pattern=D:\arduino-1.8.5\hardware\increment.bat {build.path} {build.source.path} {build.project_name}
ãããã£ãŠãåã¢ã»ã³ããª/ãã¡ãŒã ãŠã§ã¢ã®åŸã«ããã€ããªã§é ç·ãããããŒãžã§ã³çªå·ãšåãçªå·ã®ã¹ã±ããã®ã³ããŒããããŸãã ãŸããã¹ã±ããã®ãããã©ã«ããŒãDropboxã«å ¥ãããšããã®å Žãã®ãã®ããŒãžã§ã³ç®¡çã·ã¹ãã ãåŸãããŸãã
Arduino IDEããã³batãã¡ã€ã«ã®èªåã€ã³ã¯ãªã¡ã³ãããŒãžã§ã³ãèšå®ããæé ã¯ãgithubã«æçš¿ãããŠããŸãã
8.çµã¿èŸŒã¿ã®USB-UARTã¢ããã¿ãŒãããããïŒWindowsããã³Linuxã®CP2102ã®ãã©ã€ããŒã«åé¡ã¯ãããŸããïŒãã¿ãŒããã«ïŒ9600ã®é床ïŒãä»ããŠæž¬å®çµæã®åºåãè¿œå ããªãããšã¯äžå¯èœã§ããã 20ç§ã«1åã枬å®çµæãšãšã©ãŒã¡ãã»ãŒãžã衚瀺ãããŸãã
Reading MHZ19 sensor: ok
Reading DHT22 sensor: ok
===================================================
Humidity: 36.20%
Temperature: 27.20C \ 83.56F
C02: 1153 ppm
C02 average: 462 ppm
ADC: 99
UpTime: 0 days, 0 hours, 3 minutes, 45 seconds.
Time: 16:25:56 20/3/2018
===================================================
Enterãã¿ã³ãæŒããšãã·ã¹ãã æ å ±ãå«ãã¡ãã»ãŒãžãååŸã§ããŸãã
======SYSTEM-STATUS================================
Device name: OpenWindAir
Software version: 0.1.235
FreeHeap: 33824
ChipId: 13704617
FlashChipId: 1405167
FlashChipSize: 4194304
FlashChipSpeed: 40000000
CycleCount: 2204474679
Time: 16:27:6 20/3/2018
UpTime: 295
======BLYNK-STATUS=================================
Blynk token: 65a99f9e363a421c8b22d5b0162cce27
Blynk connected: 1
Notify level: 1100
Beep: 1
CO2 limit: 2000
Temperature correction: 1
======NETWORK-STATUS===============================
WiFi network: adakta2
WiFi status: 3
RSSI: -70
MAC: 18FE34D11DA9
IP: 192.168.0.152
Online: 1
======MQTT-STATUS==================================
MQTT server:narodmon.ru
MQTT port:1883
MQTT login:login
MQTT key:key
MQTT topics:
/OpenWindAir/h
/OpenWindAir/t
/OpenWindAir/f
/OpenWindAir/ppm
/OpenWindAir/status
======END-of-STATUS================================
æãäžå¿«ãªåé¡
éçºäžã«çŽé¢ããªããã°ãªããªãã£ãæãäžæå¿«ãªããšã¯ã枬å®çµæãMQTTãµãŒããŒãšBlynkã«éä¿¡ããŠãããšãã«ãããŒã¿ã®äžéšã倱ããããµãŒããŒã«å°éããªãå Žåã§ãã å€æããããã«ãMQTTãµãŒããŒã«æ¥ç¶ããŠããŒã¿ãéä¿¡ããã®ã«æ°ç§ãããå Žåãããããã®éã«Blynkã©ã€ãã©ãªã¯ãµãŒããŒãšã®æ¥ç¶ã倱ãããã®çµæããµãŒããŒãžã®åæ¥ç¶ãæåã§éå§ããªããšãå€ãã®æéãšçµæã®äžéšãããã枬å®å€ã倱ãããŸãã WiFiã¯ã©ã€ã¢ã³ã_blynkWifiClientã®ã¹ããŒã¿ã¹ã®ãã§ãã¯ãè¿œå ããæ¥ç¶ããªãå Žåã¯ã匷å¶åæ¢_blynkWifiClient.stopïŒïŒãå®è¡ããŠãããBlynkãµãŒããŒã«åæ¥ç¶ããå¿ èŠããããŸããã
if (WiFi.status() == WL_CONNECTED){ wifilost_flag = false; if (blynk_token[0] != '\0'){ if (Blynk.connected() && _blynkWifiClient.connected()){ Blynk.run(); } else{ Serial.print("\n\rReconnecting to blynk.. "); Serial.print(Blynk.connected()); if (!_blynkWifiClient.connected()){ _blynkWifiClient.stop(); Return _blynkWifiClient.connect(BLYNK_DEFAULT_DOMAIN, BLYNK_DEFAULT_PORT); } Blynk.connect(4000); Serial.print(Blynk.connected()); } }
ãããã«
ããã¯ç§ã®æåã®èšäºã§ãããHabréãžã®ç»é²ãã7幎ãçµéããŸããã éåžžã«å³ããå€æãããgovnokodã«æ³šæãæã£ãŠã¯ãããŸãããgovnokodã¯ããããŸã§ã®ãšããç§ã話ãå¯äžã®ããã°ã©ãã³ã°èšèªã§ãã
githubã®ãªããžããªã«ãããããžã§ã¯ãå šäœãç¥ãããšãã§ããŸãã
CO2ã»ã³ãµãŒãååšããŠããç§ïŒããã³ç§ã®å®¶æïŒãåã³æ¯èŠããéšå±ã«ããããšã¯ã§ããŸããã ããããæãéèŠãªããšã¯ã圌ã¯ãåè ãæ¯æããŠãæã人ãšå¹ããŠãã人ïŒç§ã§ããïŒã®ãã£ã³ãéã®æ°žé ã®æŠäºãæ¢ããŸããã
次ã«ãQlyã³ãŒããã¹ãã£ã³ãããBlynkã¢ããªã±ãŒã·ã§ã³ïŒ AppSore ã Android ïŒã䜿çšããŠãéå»3ãæéã«ç§ã®å Žæã«ã©ããªåŸ®æ°åããã£ããã調ã¹ãããšãã§ããŸãã
ãããžã§ã¯ãã¯æ©èœããŠããŸããäœãå£ããªãã§ãã ããã