|
|
@ -3,9 +3,10 @@ |
|
|
|
// load library for DHT22 sensor
|
|
|
|
// load library for DHT22 sensor
|
|
|
|
#include <DHT22.h> |
|
|
|
#include <DHT22.h> |
|
|
|
|
|
|
|
|
|
|
|
#define TRESHOLD 2 |
|
|
|
#define TRESHOLD 1 |
|
|
|
#define HYSTERESIS 1 |
|
|
|
#define HYSTERESIS 1 |
|
|
|
#define MIN_OUT_TEMP 5 // °C
|
|
|
|
#define MIN_OUT_TEMP 5 // °C
|
|
|
|
|
|
|
|
#define ALLOWED_HUMIDITY 50 // %
|
|
|
|
|
|
|
|
|
|
|
|
#define RELAY_PIN 5 |
|
|
|
#define RELAY_PIN 5 |
|
|
|
|
|
|
|
|
|
|
@ -79,15 +80,7 @@ byte off[8] = { |
|
|
|
0b11111 |
|
|
|
0b11111 |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void table(){ |
|
|
|
void setup() { |
|
|
|
|
|
|
|
// set up the LCD
|
|
|
|
|
|
|
|
lcd.begin(16, 4); |
|
|
|
|
|
|
|
lcd.createChar(0, degree);
|
|
|
|
|
|
|
|
lcd.createChar(1, tau);
|
|
|
|
|
|
|
|
lcd.createChar(2, on);
|
|
|
|
|
|
|
|
lcd.createChar(3, off);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// prepare "table" on LCD
|
|
|
|
// prepare "table" on LCD
|
|
|
|
lcd.setCursor(0,0); |
|
|
|
lcd.setCursor(0,0); |
|
|
|
lcd.print(" IN OUT"); |
|
|
|
lcd.print(" IN OUT"); |
|
|
@ -106,7 +99,17 @@ void setup() { |
|
|
|
lcd.print(" . . "); |
|
|
|
lcd.print(" . . "); |
|
|
|
lcd.write((int)0); |
|
|
|
lcd.write((int)0); |
|
|
|
lcd.print("C"); |
|
|
|
lcd.print("C"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup() { |
|
|
|
|
|
|
|
// set up the LCD
|
|
|
|
|
|
|
|
lcd.begin(16, 4); |
|
|
|
|
|
|
|
lcd.createChar(0, degree);
|
|
|
|
|
|
|
|
lcd.createChar(1, tau);
|
|
|
|
|
|
|
|
lcd.createChar(2, on);
|
|
|
|
|
|
|
|
lcd.createChar(3, off);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
table(); |
|
|
|
|
|
|
|
|
|
|
|
// set up the relay
|
|
|
|
// set up the relay
|
|
|
|
pinMode(RELAY_PIN,OUTPUT); |
|
|
|
pinMode(RELAY_PIN,OUTPUT); |
|
|
@ -177,6 +180,8 @@ void loop() { |
|
|
|
outside_temp = dht22outside.getTemperature(); |
|
|
|
outside_temp = dht22outside.getTemperature(); |
|
|
|
outside_humi = dht22outside.getHumidity(); |
|
|
|
outside_humi = dht22outside.getHumidity(); |
|
|
|
outside_state = dht22outside.getLastError(); |
|
|
|
outside_state = dht22outside.getLastError(); |
|
|
|
|
|
|
|
int secs = millis()/1000; |
|
|
|
|
|
|
|
if (secs % 3600 < 3) table(); |
|
|
|
|
|
|
|
|
|
|
|
boolean inside_error = false, outside_error = false; |
|
|
|
boolean inside_error = false, outside_error = false; |
|
|
|
|
|
|
|
|
|
|
@ -244,7 +249,7 @@ void loop() { |
|
|
|
if (inside_error || outside_error || outside_temp < MIN_OUT_TEMP){ |
|
|
|
if (inside_error || outside_error || outside_temp < MIN_OUT_TEMP){ |
|
|
|
relayOff(); |
|
|
|
relayOff(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (tau_inside > tau_outside + TRESHOLD + HYSTERESIS) { |
|
|
|
if (inside_humi > ALLOWED_HUMIDITY && tau_inside > tau_outside + TRESHOLD + HYSTERESIS) { |
|
|
|
relayOn(); |
|
|
|
relayOn(); |
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tau_inside < tau_outside + TRESHOLD) { |
|
|
|
if (tau_inside < tau_outside + TRESHOLD) { |
|
|
|