Klíma

Automatikus hőmérséklet szabályozás és szellőztetés

Lakásunk hőmérsékletét szeretnénk szabályozhatóvá tenni, valamint külső kontroll alatt tartani.

Ez azt jelenti egyrészt, hogy létrehozunk egy automatikát, melynél beállítunk egy szellőző rendszert, ha a hőmérséklet egy adott érték fölé nő, indítsa be a ventillátort, ha lecsökken, kapcsolja be a fűtést.

Másrészt azt jelenti, hogy a hőmérsékletet meg tudjuk nézni mobilunkkal, és be tudjunk távolról avatkozni: csökkenteni, vagy növelni a hőfokot. Ez azért fontos, ha elmentünk otthonról és nem zártuk le a fűtést, lezárhassuk, a jövünk haza, feltekerhessük. Ezzel sok energiát takaríthatunk meg.

Forráskód:

#include “DHT.h”
#define DHTPIN 11
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);
#define fan 13
int temperature;
long int time1;
int t1;
int t2;

void setup() {
dht.begin();
pinMode(fan, OUTPUT);
for(int i=2;i<=10;i++)
{
pinMode(i, OUTPUT);
}
pinMode(11, INPUT);
Serial.begin(9600);
/*digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
for(int i=4;i<=13;i++)
{
digitalWrite(i, HIGH);
}*/

}

void kiir (int number)
{
t1=number/10;
t2=number%10;
//Serial.println(t1);
//Serial.println(t2);

delay(10);
digitalWrite(3, HIGH);
digitalWrite(2, LOW);

switch(t1)
{

case 0 :
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
break;

case 1 :
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
break;
case 2 :
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
break;

case 3 :
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
break;

case 4 :
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
break;

case 5 :
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
break;

case 6 :
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
break;

case 7 :
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
break;

case 8 :
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);;
break;

case 9 :
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
break;

}
delay(10);

digitalWrite(2, HIGH);
digitalWrite(3, LOW);

switch(t2)
{

case 0 :
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
break;

case 1 :
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
break;
case 2 :
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
break;

case 3 :
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
break;

case 4 :
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
break;

case 5 :
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
break;

case 6 :
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
break;

case 7 :
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
break;

case 8 :
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);;
break;

case 9 :
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
break;
}
}

void loop()
{
temperature=dht.readTemperature();

Serial.println(temperature);
time1=millis();
while((time1+4000)>millis())
{
kiir(temperature);
}
if( temperature > 25)
{
digitalWrite(fan, HIGH);
}
else
{
digitalWrite(fan, LOW);
}

digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);

}