diff --git a/ESP_Kor/platformio.ini b/ESP_Kor/platformio.ini index 317bc06..2b8f958 100644 --- a/ESP_Kor/platformio.ini +++ b/ESP_Kor/platformio.ini @@ -21,3 +21,4 @@ lib_deps = ayushsharma82/WebSerial @ ^1.3.0 ottowinter/ESPAsyncWebServer-esphome @ ^3.0.0 lewapek/Nova Fitness Sds dust sensors library @ ^1.5.1 + ottowinter/AsyncMqttClient-esphome @ ^0.8.6 diff --git a/ESP_MidRoom/platformio.ini b/ESP_MidRoom/platformio.ini index 0f76e61..062d604 100644 --- a/ESP_MidRoom/platformio.ini +++ b/ESP_MidRoom/platformio.ini @@ -25,5 +25,8 @@ lib_deps = crankyoldgit/IRremoteESP8266 @ ^2.8.2 ayushsharma82/WebSerial @ ^1.3.0 ottowinter/ESPAsyncWebServer-esphome @ ^3.0.0 + ottowinter/AsyncMqttClient-esphome @ ^0.8.6 + adafruit/Adafruit BME280 Library @ ^2.2.2 + wifwaf/MH-Z19 @ ^1.5.4 ;joaolopesf/RemoteDebug @ 3.0.5 \ No newline at end of file diff --git a/ESP_Midroom2/platformio.ini b/ESP_Midroom2/platformio.ini index 7ea6563..cbf2448 100644 --- a/ESP_Midroom2/platformio.ini +++ b/ESP_Midroom2/platformio.ini @@ -7,6 +7,9 @@ ; ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html +;enjoyneering/AHT10@^1.1.0 +;ottowinter/AsyncMqttClient-esphome @ ^0.8.6 +;adafruit/Adafruit AHTX0 @ ^2.0 [env:d1_mini] platform = espressif8266 @@ -17,11 +20,10 @@ upload_port = 192.168.1.136 lib_deps = - ;enjoyneering/AHT10@^1.1.0 - ;ottowinter/AsyncMqttClient-esphome @ ^0.8.6 knolleary/PubSubClient @ ^2.8 ottowinter/ESPAsyncWebServer-esphome @ ^2.1.0 ayushsharma82/AsyncElegantOTA @ ^2.2.6 ayushsharma82/WebSerial @ ^1.3.0 jwrw/ESP_EEPROM @ ^2.0.0 - adafruit/Adafruit AHTX0 @ ^2.0.3 + beegee-tokyo/DHT sensor library for ESPx @ ^1.19 + diff --git a/ESP_Midroom2/src/main.cpp b/ESP_Midroom2/src/main.cpp index a758d09..205ec74 100644 --- a/ESP_Midroom2/src/main.cpp +++ b/ESP_Midroom2/src/main.cpp @@ -1,5 +1,6 @@ #include -#include +//#include +#include "DHTesp.h" #include #include #include @@ -24,8 +25,11 @@ #define LAMP_OUT (D5) -Adafruit_AHTX0 aht; -sensors_event_t humidity, temp; +//Adafruit_AHTX0 aht; +DHTesp dht; +TempAndHumidity sTaH; + +//sensors_event_t humidity, temp; float temp_out, hum_out; WiFiClient espClient; @@ -94,16 +98,18 @@ void setup() { pinMode(LED_MQ, OUTPUT); pinMode(LED_WRK, OUTPUT); pinMode(LAMP_OUT, OUTPUT); - if (! aht.begin()) { - Serial.println("Could not find AHT? Check wiring"); - aht_pesent = false; - } else{ - if(aht.getEvent(&humidity, &temp)){ - temp_out = temp.temperature; - hum_out = humidity.relative_humidity; - } - aht_pesent = true; - } + dht.setup(D1, DHTesp::DHT22); + delay(dht.getMinimumSamplingPeriod()); + // if (! aht.begin()) { + // Serial.println("Could not find AHT? Check wiring"); + // aht_pesent = false; + // } else{ + // if(aht.getEvent(&humidity, &temp)){ + // temp_out = temp.temperature; + // hum_out = humidity.relative_humidity; + // } + // aht_pesent = true; + // } EEPROM.begin(4); EEPROM.get(0, led_intense); Serial.print("Led intense: "); @@ -137,17 +143,18 @@ void loop() { if(stled + 300 < millis()){ digitalWrite(LED_WRK, HIGH); } - if(cRun + 1000 <= millis()){ + if(cRun + 2000 <= millis()){ cRun = millis(); Serial.println(bSecs); - if(aht_pesent && aht.getEvent(&humidity, &temp)){ - temp_out += (temp.temperature- temp_out) / 600; - hum_out += (humidity.relative_humidity - hum_out) / 600; + sTaH = dht.getTempAndHumidity(); + if(dht.getStatus() == dht.ERROR_NONE){ + temp_out += (sTaH.temperature - temp_out) / 300; + hum_out += (sTaH.humidity - hum_out) / 300; WebSerial.print("Temp: "); - WebSerial.print(temp.temperature); + WebSerial.print(sTaH.temperature); WebSerial.print(", Hum: "); - WebSerial.println(humidity.relative_humidity); - if(bSecs == 59){ + WebSerial.println(sTaH.temperature); + if(bSecs == 29){ bSecs = 0; digitalWrite(LED_WRK, LOW); sprintf(v, "%.1f", temp_out); @@ -156,7 +163,7 @@ void loop() { client.publish(TOPIC"humout", v); } } - if((bSecs % 30) == 0){ + if((bSecs % 15) == 0){ wMins += 0.5; Serial.println("halfMinTick"); sprintf(v, "%.1f", wMins); @@ -240,4 +247,4 @@ void reconnect() { } } digitalWrite(LED_MQ, HIGH); -} \ No newline at end of file +} diff --git a/I2C Scan/src/main.cpp b/I2C Scan/src/main.cpp index e9e376e..c4a7f0e 100644 --- a/I2C Scan/src/main.cpp +++ b/I2C Scan/src/main.cpp @@ -18,10 +18,10 @@ void setup() { } Serial.println (); - #undef SCL - #undef SDA - #define SCL 32 - #define SDA 33 + // #undef SCL + // #undef SDA + // #define SCL 32 + // #define SDA 33 Serial.print("SCL=");Serial.println (SCL); Serial.print("SDA=");Serial.println (SDA); //Serial.print("PWSCL=");Serial.println (PIN_WIRE_SCL); @@ -31,9 +31,11 @@ void setup() { byte count = 0; Wire.begin(SDA, SCL); - for (byte i = 8; i < 120; i++) + for (byte i = 1; i < 15; i++) { + Serial.print("Scan adr ");Serial.print(i, 16); Wire.beginTransmission (i); + Serial.println(" beg trans"); if (Wire.endTransmission () == 0) { Serial.print ("Found address: ");