-
Notifications
You must be signed in to change notification settings - Fork 1
/
ac_controller.ino
55 lines (40 loc) · 872 Bytes
/
ac_controller.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
/*
* Air conditioner controller
* Maxime MOREILLON
*
* Board type: Wemos D1 Mini
*
*/
#include "IotKernel.h"
// Libraries
#include <DHT.h> // Temperature and humidity sensor
//#include "aircon_kitchen_nagoya.h";
#include "aircon_bedroom_nagoya.h";
// Pin mapping
#define DHT_PIN D1
#define PIR_PIN D2
#define IR_LED_PIN D6
#define IR_EMITTER_PIN D6 // alias
// DHT
#define DHT_PUBLISH_PERIOD 60000 // [ms] = 1 minute
#define DHT_READ_PERIOD 10000 // [ms] = 10 seconds
IotKernel iot_kernel("aircon","0.0.1");
// AC variables
const char* AC_state = "unknown";
// DHT variables
DHT dht(DHT_PIN, DHT22);
void setup() {
// Mandatory initial delay
delay(10);
// IO init
pinMode(IR_LED_PIN, OUTPUT);
pinMode(PIR_PIN, INPUT);
dht.begin();
iot_kernel.init();
mqtt_config();
}
void loop() {
iot_kernel.loop();
read_PIR();
read_DHT();
}