Add WiFi functionality to any AC unit by emulating an infrared remote control and create an interface you can operate from your smartphone.
Devices and components
M5Stack ATOM Lite
Software and tools
Arduino IoT Cloud
Project description
Hardware
Software
DaikinHeatpumpIR.h
Remote
a string variable called mode
mode
an integer variable called temperature
temperature
Live updates
Optional: Closing the Loop
Sketch
1#include "thingProperties.h"
2#include <Button2.h>
3#include <DaikinHeatpumpIR.h>
4
5
6constexpr int IR_PIN = 12;
7constexpr int BTN_PIN = 39;
8
9IRSenderESP32 irSender(IR_PIN, 0);
10DaikinHeatpumpIR irHeatpump;
11Button2 button;
12
13void setup() {
14 // Connect to Arduino IoT Cloud
15 initProperties();
16 ArduinoCloud.begin(ArduinoIoTPreferredConnection);
17
18 // Initialize variables and pins
19 pinMode(39, INPUT_PULLUP);
20 //pinMode(IR_PIN, OUTPUT);
21
22 button.begin(BTN_PIN);
23 button.setTapHandler([](Button2& btn) {
24 mode = (mode == "OFF") ? "COOL" : "OFF";
25 send();
26 });
27}
28
29void loop() {
30 ArduinoCloud.update();
31 button.loop();
32}
33
34// Handle incoming messages
35void onOnOffChange() {
36 send();
37}
38
39void send() {
40 if (mode == "HEAT") {
41 irHeatpump.send(irSender, POWER_ON, MODE_HEAT, FAN_AUTO, temperature, VDIR_UP, HDIR_AUTO);
42 } else if (mode == "COOL") {
43 irHeatpump.send(irSender, POWER_ON, MODE_COOL, FAN_AUTO, temperature, VDIR_UP, HDIR_AUTO);
44 } else if (mode == "DRY") {
45 irHeatpump.send(irSender, POWER_ON, MODE_DRY, FAN_AUTO, temperature, VDIR_UP, HDIR_AUTO);
46 } else {
47 irHeatpump.send(irSender, POWER_OFF, MODE_HEAT, FAN_AUTO, 30, VDIR_UP, HDIR_AUTO);
48 }
49}
50
51/*
52 Since Mode is READ_WRITE variable, onModeChange() is
53 executed every time a new value is received from IoT Cloud.
54*/
55void onModeChange() {
56 // Add your code here to act upon Mode change
57 send();
58}
59/*
60 Since Temperature is READ_WRITE variable, onTemperatureChange() is
61 executed every time a new value is received from IoT Cloud.
62*/
63void onTemperatureChange() {
64 // Add your code here to act upon Temperature change
65 send();
66}
Note: Content and images are from: https://projecthub.arduino.cc/, with some modifications.
If you want it removed due to copyright reasons, please leave a comment. Thank you.
I want to share this article more widely so that everyone knows about Arduino and your project.