-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemperatura.ino
63 lines (52 loc) · 2.27 KB
/
Temperatura.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/////////////////////////////////////////////////////////////////
// Controlamos las temperaturas para
// activar o desactivar calentador y ventiladores
/////////////////////////////////////////////////////////////////
void check_temp(){
contador_temp ++; // LEE LOS VALORES DE LAS TEMPERATURAS
sensors.requestTemperatures(); // call sensors.requestTemperatures() to issue a global
// temperature request to all devices on the bus
temperatura_agua_temp += (sensors.getTempC(sensor_agua)); // Serial.print(temperatura_agua_temp);
temperatura_habitacion_temp += (sensors. getTempC(sensor_habitacion)); // lee temperatura habitacion.
temperatura_disipador_temp += (sensors.getTempC(sensor_disipador)); //read heatsink temperature
if(contador_temp == 10)
{
temp_agua = temperatura_agua_temp / 10;
tempHB = temperatura_habitacion_temp / 10;
tempD = temperatura_disipador_temp / 10;
contador_temp = 0;
temperatura_agua_temp = 0;
temperatura_habitacion_temp = 0;
temperatura_disipador_temp = 0;
}
// ACTUA EN FUNCION DE LOS VALORES DE LA TEMPERATURA
if (temp_agua != -127 && temp_agua != 85){
if (temp_agua <= temp_agua_des-temperatura_margen){
SetRele(calentador,HIGH); // Encendemos Calentador
led1.on();
estado1 = 0;
// Serial.print("Enciende calentador: "); Serial.print(temp_agua); Serial.print(" "); Serial.println(temp_agua_des-temperatura_margen);
alarmas = 1;
}
if (temp_agua >= temp_agua_des+temperatura_margen){
SetRele(calentador,LOW); // Apagamos Calentador
led1.off();
estado1 = 1;
// Serial.print("Apaga calentador");Serial.print(temp_agua); Serial.print(" "); Serial.println(temp_agua_des+temperatura_margen);
alarmas = 0;
}
/* Serial.println(temp_agua);
Serial.print(" ");
Serial.println(temp_agua_des+0.5);
Serial.print(" ");
Serial.println(EEPROM.read(1));
*/
}
else
{
SetRele(calentador,LOW); // Apagamos Calentador
}
}
/////////////////////////////////////////////////////////////////
//Fin controlTemperatura
/////////////////////////////////////////////////////////////////