-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEdsonIoT.ino
82 lines (66 loc) · 1.45 KB
/
EdsonIoT.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "DHT.h"
#define DHTPIN 4
#define DHTTYPE DHT22
#define temp_low 5
#define temp_high 19
#define temp_ok 21
#define humidity_low 23
#define humidity_ok 15
#define humidity_high 16
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println();
dht.begin();
//temperatura
pinMode(temp_low,OUTPUT);
pinMode(temp_high,OUTPUT);
pinMode(temp_ok,OUTPUT);
//humidity
pinMode(humidity_low,OUTPUT);
pinMode(humidity_high,OUTPUT);
pinMode(humidity_ok,OUTPUT);
}
void loop() {
delay(1000);
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" °C");
//bloco de temperatura
if (t < 21.5){
digitalWrite(temp_low,HIGH);
digitalWrite(temp_high,LOW);
digitalWrite(temp_ok,LOW);
}
if (t > 22.5) {
digitalWrite(temp_high,HIGH);
digitalWrite(temp_low,LOW);
digitalWrite(temp_ok,LOW);
}
if (t > 21.6 or t < 22.4){
digitalWrite(temp_high,LOW);
digitalWrite(temp_low,LOW);
digitalWrite(temp_ok,HIGH);
}
//bloco de humidade
if (h < 40.0) {
digitalWrite(humidity_high,HIGH);
digitalWrite(humidity_low,LOW);
digitalWrite(humidity_ok,LOW);
}
if (h > 40.0 or h < 70.0){
digitalWrite(humidity_high,LOW);
digitalWrite(humidity_low,LOW);
digitalWrite(humidity_ok,HIGH);
}
if (h > 70.0){
digitalWrite(humidity_high,HIGH);
digitalWrite(humidity_low,LOW);
digitalWrite(humidity_ok,LOW);
}
}