Updated indoor examples

This commit is contained in:
Achim
2023-04-13 09:33:26 +07:00
parent 43f599a0a7
commit 6314e52770
4 changed files with 61 additions and 68 deletions

View File

@ -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("<p>This is just a text paragraph</p>");
wifiManager.addParameter(&custom_text);
WiFiManagerParameter parameter("parameterId", "Parameter Label", "default value", 40);
wifiManager.addParameter(&parameter);
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