-
Notifications
You must be signed in to change notification settings - Fork 0
/
windybox.ino
71 lines (60 loc) · 3.65 KB
/
windybox.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
#include "DHT.h"
#include <IRremote.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
long previousMillis = 0;
long logInterval = 5000;
// pin 3
IRsend irsend;
unsigned int livingroomFAN[67] = {9050, 4450, 600, 500, 600, 500, 650, 500, 600, 550, 600, 500, 600, 1650, 600, 500, 650, 500, 600, 1650, 600, 1650, 600, 1650, 600, 1600, 650, 1650, 600, 500, 600, 1650, 600, 1650, 600, 500, 600, 1650, 600, 550, 600, 1650, 600, 1650, 600, 500, 600, 550, 600, 500, 600, 1650, 600, 500, 650, 1650, 550, 550, 600, 500, 600, 1650, 600, 1650, 600, 1650, 600};
unsigned int livingroomMODE[67] = {9050, 4450, 600, 500, 650, 500, 600, 500, 650, 500, 600, 500, 600, 1650, 600, 550, 600, 500, 600, 1650, 600, 1650, 600, 1650, 600, 1650, 600, 1650, 600, 500, 600, 1650, 600, 1650, 600, 1650, 600, 500, 650, 500, 600, 1650, 600, 500, 600, 550, 600, 500, 600, 550, 600, 500, 600, 1650, 600, 1650, 600, 550, 550, 1650, 650, 1650, 550, 1650, 600, 1650, 600};
unsigned int livingroomPOWER[67] = {9050, 4400, 650, 500, 600, 500, 650, 500, 600, 500, 650, 500, 600, 1600, 650, 500, 600, 550, 600, 1600, 650, 1600, 650, 1650, 600, 1600, 600, 1650, 650, 500, 600, 1650, 600, 1650, 600, 500, 600, 1650, 600, 500, 650, 500, 600, 550, 600, 500, 600, 500, 600, 550, 600, 1650, 600, 500, 600, 1650, 600, 1650, 600, 1650, 600, 1650, 600, 1650, 600, 1650, 600};
unsigned int livingroomTEMPMINUS[67] = {9050, 4450, 600, 500, 650, 500, 600, 500, 650, 500, 600, 500, 600, 1650, 600, 550, 600, 500, 600, 1650, 600, 1650, 600, 1650, 600, 1650, 600, 1650, 600, 500, 600, 1650, 600, 1650, 600, 1650, 600, 500, 650, 500, 600, 550, 600, 1600, 600, 550, 600, 500, 650, 500, 600, 500, 600, 1650, 600, 1650, 600, 1650, 600, 500, 650, 1650, 550, 1700, 550, 1650, 600};
unsigned int livingroomTEMPPLUS[67] = {9050, 4400, 650, 500, 600, 550, 600, 500, 600, 500, 650, 500, 600, 1650, 600, 500, 600, 550, 600, 1650, 600, 1650, 600, 1650, 600, 1650, 600, 1650, 550, 550, 600, 1650, 600, 1650, 600, 500, 600, 1650, 650, 500, 600, 1650, 600, 500, 600, 550, 600, 500, 600, 550, 550, 1650, 650, 500, 600, 1650, 600, 500, 600, 1650, 600, 1700, 550, 1650, 600, 1650, 600};
unsigned int livingroomTIMER[67] = {9050, 4450, 600, 500, 650, 500, 600, 550, 600, 500, 600, 500, 650, 1600, 650, 500, 600, 500, 600, 1650, 600, 1650, 600, 1650, 600, 1650, 600, 1650, 600, 500, 600, 1650, 650, 1650, 550, 1650, 600, 550, 600, 500, 600, 1650, 600, 1650, 600, 550, 600, 500, 600, 550, 550, 550, 600, 1650, 600, 1650, 600, 500, 600, 550, 600, 1650, 600, 1650, 600, 1650, 550};
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
unsigned long currentMillis = millis();
String cmd;
if (currentMillis - previousMillis > logInterval) {
previousMillis = currentMillis;
logTemperature();
}
if (Serial.available() > 0) {
cmd = Serial.readStringUntil('\n');
cmd.trim();
sendIr(cmd);
}
}
void logTemperature() {
float humidity = dht.readHumidity();
float degrees_c = dht.readTemperature();
if(!isnan(humidity) && !isnan(degrees_c)) {
Serial.print("Humidity:");
Serial.print(humidity);
Serial.println(":%");
Serial.print("Temperature:");
Serial.print(degrees_c);
Serial.println(":C");
}
}
void sendIr(String cmd) {
Serial.println(cmd);
if (cmd == "POWER") {
irsend.sendRaw(livingroomPOWER, 67, 38);
} else if (cmd == "TEMPPLUS") {
irsend.sendRaw(livingroomTEMPPLUS, 67, 38);
} else if (cmd == "TEMPMINUS") {
irsend.sendRaw(livingroomTEMPMINUS, 67, 38);
} else if (cmd == "TIMER") {
irsend.sendRaw(livingroomTIMER, 67, 38);
} else if (cmd == "FAN") {
irsend.sendRaw(livingroomFAN, 67, 38);
} else if (cmd == "MODE") {
irsend.sendRaw(livingroomMODE, 67, 38);
}
}