diff --git a/examples/DIY_OUTDOOR/DIY_OUTDOOR.ino b/examples/DIY_OUTDOOR/DIY_OUTDOOR.ino index de978f7..04acb76 100644 --- a/examples/DIY_OUTDOOR/DIY_OUTDOOR.ino +++ b/examples/DIY_OUTDOOR/DIY_OUTDOOR.ino @@ -1,3 +1,23 @@ +/* +Important: This code is only for the AirGradient DIY OUTDOOR. + +Build Instructions: https://www.airgradient.com/open-airgradient/instructions/diy-outdoor/ + +Kits (including a pre-soldered version) are available: https://www.airgradient.com/open-airgradient/kits/ + +Configuration: +Install required libraries +Patch PMS library to accept temperature and humidity from PMS5003T + +If you have any questions please visit our forum at https://forum.airgradient.com/ + +If you are a school or university contact us for a free trial on the AirGradient platform. +https://www.airgradient.com/ + +License: CC BY-NC 4.0 Attribution-NonCommercial 4.0 International + +*/ + #include "PMS.h" #include "SoftwareSerial.h" #include @@ -7,25 +27,18 @@ #include #include -#include "ClosedCube_SHT31D.h" - SoftwareSerial softSerial(D6, D5); //(RX, TX) SoftwareSerial soft2(D3, D7); //(RX, TX) -ClosedCube_SHT31D sht3xd; - PMS pms(softSerial); PMS pms2(soft2); PMS::DATA data; int pm1 = 0; -int pm2 = 0; -float temp = 0; -int hum = 0; - float temp_pm1 = 0; float hum_pm1 = 0; +int pm2 = 0; float temp_pm2 = 0; float hum_pm2 = 0; @@ -33,14 +46,13 @@ String APIROOT = "http://hw.airgradient.com/"; void setup() { - Serial.begin(9600); - Serial.println("hhi"); + Serial.begin(115200); + Serial.println("Welcome to AirGradient"); softSerial.begin(9600); soft2.begin(9600); Wire.begin(); - sht3xd.begin(0x44); pinMode(D7, OUTPUT); - + connectToWifi(); } @@ -53,7 +65,7 @@ void loop() else { digitalWrite(D7, LOW); } - + if (pms.read(data)){ pm1 = data.PM_AE_UG_2_5; temp_pm1 = data.AMB_TMP; @@ -66,6 +78,7 @@ void loop() Serial.println(hum_pm1); Serial.println(); delay(1000); + sendToServerPM1(); } if (pms2.read(data)){ pm2 = data.PM_AE_UG_2_5; @@ -79,21 +92,13 @@ void loop() Serial.println(hum_pm2); Serial.println(); delay(1000); - - temp = sht3xd.readTempAndHumidity(SHT3XD_REPEATABILITY_LOW, SHT3XD_MODE_CLOCK_STRETCH, 50).t; - hum = sht3xd.readTempAndHumidity(SHT3XD_REPEATABILITY_LOW, SHT3XD_MODE_CLOCK_STRETCH, 50).rh; - - Serial.println(temp); - Serial.println(hum); - - sendToServer(); - delay(1000); - sendToServerPM1(); - delay(1000); sendToServerPM2(); - } + if (hum_pm1 > 0 && hum_pm2 > 0) sendToServer(); + + delay(30000); + } @@ -101,8 +106,8 @@ void loop() void sendToServer() { String payload = "{\"wifi\":" + String(WiFi.RSSI()) + ", \"pm02\":" + String((pm1+pm2)/2) - + ", \"atmp\":" + String(temp) - + ", \"rhum\":" + String(hum) + + ", \"atmp\":" + String((temp_pm1 + temp_pm2) / 20) + + ", \"rhum\":" + String((hum_pm1 + hum_pm2) / 20) + "}"; if(WiFi.status()== WL_CONNECTED){ @@ -192,10 +197,10 @@ void sendToServerPM2() { WiFiManager wifiManager; //WiFi.disconnect(); //to delete previous saved hotspot String HOTSPOT = "AIRGRADIENT-" + String(ESP.getChipId(), HEX); - wifiManager.setTimeout(60); + wifiManager.setTimeout(120); if (!wifiManager.autoConnect((const char * ) HOTSPOT.c_str())) { Serial.println("failed to connect and hit timeout"); delay(6000); } - + } diff --git a/examples/DIY_PRO_V3_7/DIY_PRO_V3_7.ino b/examples/DIY_PRO_V3_7/DIY_PRO_V3_7.ino index 0d943f1..e7cabf7 100644 --- a/examples/DIY_PRO_V3_7/DIY_PRO_V3_7.ino +++ b/examples/DIY_PRO_V3_7/DIY_PRO_V3_7.ino @@ -23,7 +23,7 @@ If you have any questions please visit our forum at https://forum.airgradient.co If you are a school or university contact us for a free trial on the AirGradient platform. https://www.airgradient.com/ -MIT License +License: CC BY-NC 4.0 Attribution-NonCommercial 4.0 International */ @@ -51,7 +51,7 @@ NOxGasIndexAlgorithm nox_algorithm; // time in seconds needed for NOx conditioning uint16_t conditioning_s = 10; -// for peristent saving and loading +// for persistent saving and loading int addr = 0; byte value; @@ -232,32 +232,29 @@ void setConfig() { inUSAQI = true; } if (buttonConfig == 4) { - updateOLED2("Temp. in C", "PM in ug/m3", "Display Top"); + updateOLED2("Temp. in C", "PM in ug/m3", "Display Bottom"); u8g2.setDisplayRotation(U8G2_R0); inF = false; inUSAQI = false; } if (buttonConfig == 5) { - updateOLED2("Temp. in C", "PM in US AQI", "Display Top"); + updateOLED2("Temp. in C", "PM in US AQI", "Display Bottom"); u8g2.setDisplayRotation(U8G2_R0); inF = false; inUSAQI = true; } if (buttonConfig == 6) { - updateOLED2("Temp. in F", "PM in ug/m3", "Display Top"); + updateOLED2("Temp. in F", "PM in ug/m3", "Display Bottom"); u8g2.setDisplayRotation(U8G2_R0); inF = true; inUSAQI = false; } if (buttonConfig == 7) { - updateOLED2("Temp. in F", "PM in US AQI", "Display Top"); + updateOLED2("Temp. in F", "PM in US AQI", "Display Bottom"); u8g2.setDisplayRotation(U8G2_R0); inF = true; inUSAQI = true; } - - - // to do // if (buttonConfig == 8) { // updateOLED2("CO2", "Manual", "Calibration");