Libs download
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <Adafruit_AHTX0.h>
|
||||
//#include <Adafruit_AHTX0.h>
|
||||
#include "DHTesp.h"
|
||||
#include <ArduinoOTA.h>
|
||||
#include <Ticker.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user