-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathESP32-AirConditioner.ino
More file actions
77 lines (63 loc) · 2.31 KB
/
Copy pathESP32-AirConditioner.ino
File metadata and controls
77 lines (63 loc) · 2.31 KB
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
/////// Pairing Code 112-23-344
#include "HomeSpan.h"
#include "IRController.h"
#include "FanAccessory.h"
#include "CustomWebInterface.h"
#include "ThermostatAccessory.h"
#include "DryingShutdownAccessory.h"
#define STATUS_LED_PIN 48 // pin for status LED
const uint16_t sendPin = 4; // Define the GPIO pin for the IR LED
const uint16_t recvPin = 15; // Pin where the IR receiver is connected
const uint32_t kBaudRate = 115200;
const uint16_t kCaptureBufferSize = 2048;
const uint8_t kTimeout = 15;
FanAccessory *fanAccessory = nullptr;
ThermostatAccessory *thermostatAccessory = nullptr;
DryingShutdownAccessory *dryingAccessory = nullptr;
IRController irController(sendPin, recvPin, kCaptureBufferSize, kTimeout, true);
void setup() {
Serial.begin(kBaudRate);
irController.beginReceive();
irController.beginSend();
homeSpan.setApSSID("ESP32 Ac Controller");
homeSpan.setApPassword("123456789");
homeSpan.setStatusPixel(STATUS_LED_PIN, 240, 100, 5);
homeSpan.setHostNameSuffix("-ac-controller");
homeSpan.setPortNum(1201); // change port number for HomeSpan so we can use port 80 for the Web Server
// homeSpan.enableOTA(); // enable OTA updates
homeSpan.setWifiCallback(setWebInterface);
homeSpan.setPairingCode("11223344");
homeSpan.enableAutoStartAP();
homeSpan.begin(Category::Bridges, "AC_Bridge");
// homeSpan.enableWebLog(10, "pool.ntp.org", "UTC+3");
// homeSpan.setApTimeout(300);
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("Air Conditioner");
new Characteristic::Model("ESP32 AC Model");
new Characteristic::FirmwareRevision("1.0.0");
thermostatAccessory = new ThermostatAccessory(&irController);
fanAccessory = new FanAccessory(&irController);
if (irController.isDryingBeforeShutdownEnabled()) {
dryingAccessory = new DryingShutdownAccessory(&irController);
}
homeSpan.autoPoll();
}
void loop() {
irController.processPendingCommand();
if (thermostatAccessory) {
thermostatAccessory->poll();
}
if (dryingAccessory) {
dryingAccessory->poll();
}
webServerLoop();
delay(2);
}
void setWebInterface() {
setupWebInterface(irController);
}