diff --git a/examples/DIY_BASIC/DIY_BASIC.ino b/examples/DIY_BASIC/DIY_BASIC.ino index 873d957..ac36da5 100644 --- a/examples/DIY_BASIC/DIY_BASIC.ino +++ b/examples/DIY_BASIC/DIY_BASIC.ino @@ -85,9 +85,7 @@ void setup() if (connectWIFI) { connectToWifi(); } - - updateOLED2("Warming", "up the", "sensors"); - + updateOLED2("Warm Up", "Serial#", String(ESP.getChipId(), HEX)); ag.CO2_Init(); ag.PMS_Init(); ag.TMP_RH_Init(0x44); @@ -207,9 +205,9 @@ void sendToServer() { WiFiManager wifiManager; //WiFi.disconnect(); //to delete previous saved hotspot String HOTSPOT = "AG-" + String(ESP.getChipId(), HEX); - updateOLED2("Connect", "Wifi", HOTSPOT); + updateOLED2("Connect", "Wifi AG-", String(ESP.getChipId(), HEX)); delay(2000); - wifiManager.setTimeout(60); + wifiManager.setTimeout(90); if (!wifiManager.autoConnect((const char * ) HOTSPOT.c_str())) { updateOLED2("Booting", "offline", "mode"); Serial.println("failed to connect and hit timeout"); 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 3bf961e..2f7ba68 100644 --- a/examples/DIY_PRO_V3_7/DIY_PRO_V3_7.ino +++ b/examples/DIY_PRO_V3_7/DIY_PRO_V3_7.ino @@ -52,14 +52,14 @@ NOxGasIndexAlgorithm nox_algorithm; uint16_t conditioning_s = 10; // for peristent saving and loading -int addr = 0; +int addr = 4; byte value; // Display bottom right -//U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); +U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Replace above if you have display on top left -U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R2, /* reset=*/ U8X8_PIN_NONE); +//U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R2, /* reset=*/ U8X8_PIN_NONE); // CONFIGURATION START @@ -108,7 +108,7 @@ unsigned long previousTempHum = 0; float temp = 0; int hum = 0; -int buttonConfig=0; +int buttonConfig=4; int lastState = LOW; int currentState; unsigned long pressedTime = 0; @@ -143,7 +143,7 @@ void setup() { connectToWifi(); } - updateOLED2("Warming up the", "sensors.", ""); + updateOLED2("Warming Up", "Serial Number:", String(ESP.getChipId(), HEX)); sgp41.begin(Wire); ag.CO2_Init(); ag.PMS_Init(); @@ -232,25 +232,25 @@ 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; @@ -400,19 +400,8 @@ void sendToServer() { WiFiManager wifiManager; //WiFi.disconnect(); //to delete previous saved hotspot String HOTSPOT = "AG-" + String(ESP.getChipId(), HEX); - updateOLED2("60s to connect", "to Wifi Hotspot", HOTSPOT); - wifiManager.setTimeout(60); - - - WiFiManagerParameter custom_text("

This is just a text paragraph

"); - wifiManager.addParameter(&custom_text); - - WiFiManagerParameter parameter("parameterId", "Parameter Label", "default value", 40); - wifiManager.addParameter(¶meter); - - - Serial.println("Parameter 1:"); - Serial.println(parameter.getValue()); + updateOLED2("90s to connect", "to Wifi Hotspot", HOTSPOT); + wifiManager.setTimeout(90); if (!wifiManager.autoConnect((const char * ) HOTSPOT.c_str())) { updateOLED2("booting into", "offline mode", ""); @@ -420,9 +409,6 @@ void sendToServer() { delay(6000); } - Serial.println("Parameter 2:"); - Serial.println(parameter.getValue()); - } // Calculate PM2.5 US AQI diff --git a/examples/DIY_PRO_V4_2/DIY_PRO_V4_2.ino b/examples/DIY_PRO_V4_2/DIY_PRO_V4_2.ino index d50d084..638e0ea 100644 --- a/examples/DIY_PRO_V4_2/DIY_PRO_V4_2.ino +++ b/examples/DIY_PRO_V4_2/DIY_PRO_V4_2.ino @@ -1,11 +1,11 @@ /* -Important: This code is only for the DIY PRO PCB Version 4.2 that needs different code due to different wiring of the push button. +Important: This code is only for the DIY PRO PCB Version 3.7 that has a push button mounted. This is the code for the AirGradient DIY PRO Air Quality Sensor with an ESP8266 Microcontroller with the SGP40 TVOC module from AirGradient. It is a high quality sensor showing PM2.5, CO2, Temperature and Humidity on a small display and can send data over Wifi. -Build Instructions: https://www.airgradient.com/open-airgradient/instructions/diy-pro-v42/ +Build Instructions: https://www.airgradient.com/open-airgradient/instructions/diy-pro-v37/ Kits (including a pre-soldered version) are available: https://www.airgradient.com/open-airgradient/kits/ @@ -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/ -License: CC BY-NC 4.0 Attribution-NonCommercial 4.0 International +CC BY-SA 4.0 Attribution-ShareAlike 4.0 International License */ @@ -51,8 +51,8 @@ NOxGasIndexAlgorithm nox_algorithm; // time in seconds needed for NOx conditioning uint16_t conditioning_s = 10; -// for persistent saving and loading -int addr = 0; +// for peristent saving and loading +int addr = 4; byte value; // Display bottom right @@ -108,8 +108,8 @@ unsigned long previousTempHum = 0; float temp = 0; int hum = 0; -int buttonConfig=0; -int lastState = HIGH; +int buttonConfig=4; +int lastState = LOW; int currentState; unsigned long pressedTime = 0; unsigned long releasedTime = 0; @@ -117,7 +117,6 @@ unsigned long releasedTime = 0; void setup() { Serial.begin(115200); Serial.println("Hello"); - u8g2.setBusClock(100000); u8g2.begin(); //u8g2.setDisplayRotation(U8G2_R0); @@ -130,14 +129,12 @@ void setup() { updateOLED2("Press Button", "Now for", "Config Menu"); delay(2000); - pinMode(D7, INPUT_PULLUP); - currentState = digitalRead(D7); - if (currentState == LOW) + if (currentState == HIGH) { updateOLED2("Entering", "Config Menu", ""); delay(3000); - lastState = HIGH; + lastState = LOW; inConf(); } @@ -146,7 +143,7 @@ void setup() { connectToWifi(); } - updateOLED2("Warming up the", "sensors.", ""); + updateOLED2("Warming Up", "Serial Number:", String(ESP.getChipId(), HEX)); sgp41.begin(Wire); ag.CO2_Init(); ag.PMS_Init(); @@ -154,9 +151,6 @@ void setup() { } void loop() { - - currentState = digitalRead(D7); - currentMillis = millis(); updateTVOC(); updateOLED(); @@ -170,27 +164,20 @@ void inConf(){ setConfig(); currentState = digitalRead(D7); - if (currentState){ - Serial.println("currentState: high"); - } else { - Serial.println("currentState: low"); - } - - - if(lastState == HIGH && currentState == LOW) { + if(lastState == LOW && currentState == HIGH) { pressedTime = millis(); } - else if(lastState == LOW && currentState == HIGH) { + else if(lastState == HIGH && currentState == LOW) { releasedTime = millis(); long pressDuration = releasedTime - pressedTime; if( pressDuration < 1000 ) { buttonConfig=buttonConfig+1; - if (buttonConfig>3) buttonConfig=0; + if (buttonConfig>7) buttonConfig=0; } } - if (lastState == LOW && currentState == LOW){ + if (lastState == HIGH && currentState == HIGH){ long passedDuration = millis() - pressedTime; if( passedDuration > 4000 ) { // to do @@ -221,30 +208,52 @@ void inConf(){ void setConfig() { if (buttonConfig == 0) { - updateOLED2("Temp. in C", "PM in ug/m3", "Long Press Saves"); - u8g2.setDisplayRotation(U8G2_R0); + updateOLED2("Temp. in C", "PM in ug/m3", "Display Top"); + u8g2.setDisplayRotation(U8G2_R2); inF = false; inUSAQI = false; } else if (buttonConfig == 1) { - updateOLED2("Temp. in C", "PM in US AQI", "Long Press Saves"); - u8g2.setDisplayRotation(U8G2_R0); + updateOLED2("Temp. in C", "PM in US AQI", "Display Top"); + u8g2.setDisplayRotation(U8G2_R2); inF = false; inUSAQI = true; } else if (buttonConfig == 2) { - updateOLED2("Temp. in F", "PM in ug/m3", "Long Press Saves"); - u8g2.setDisplayRotation(U8G2_R0); + updateOLED2("Temp. in F", "PM in ug/m3", "Display Top"); + u8g2.setDisplayRotation(U8G2_R2); inF = true; inUSAQI = false; } else if (buttonConfig == 3) { - updateOLED2("Temp. in F", "PM in US AQI", "Long Press Saves"); + updateOLED2("Temp. in F", "PM in US AQI", "Display Top"); + u8g2.setDisplayRotation(U8G2_R2); + inF = true; + inUSAQI = true; + } else if (buttonConfig == 4) { + 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 Bottom"); + u8g2.setDisplayRotation(U8G2_R0); + inF = false; + inUSAQI = true; + } else if (buttonConfig == 6) { + updateOLED2("Temp. in F", "PM in ug/m3", "Display Bottom"); + u8g2.setDisplayRotation(U8G2_R0); + inF = true; + inUSAQI = false; + } else if (buttonConfig == 7) { + updateOLED2("Temp. in F", "PM in US AQI", "Display Bottom"); u8g2.setDisplayRotation(U8G2_R0); inF = true; inUSAQI = true; - } else { - updateOLED2("Short Press", "Button for", "Options"); } + + + // to do - // if (buttonConfig == 4) { + // if (buttonConfig == 8) { // updateOLED2("CO2", "Manual", "Calibration"); // } } diff --git a/library.properties b/library.properties index 02b783b..7f72465 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=AirGradient Air Quality Sensor -version=2.4.0 +version=2.4.1 author=AirGradient maintainer=AirGradient sentence=ESP8266 library for an air quality sensor featuring PM2.5, CO2, Temperature, TVOC and Humidity with OLED display.