Arduino framework library for controlling Midea home appliances using the UART protocol.
Control is possible with a custom dongle. You can make it yourself according to numerous instructions on the Internet, or you can buy a ready-made one in Tindie Shop, thereby supporting me and my work.
A far from complete list of supported brands:
It's simple.
- Create appliance instance of
dudanov::midea::ac::AirConditioner
. - Set serial stream interface and communication mode to
9600 8N1
. - Add
setup()
andloop()
methods to the same-named global functions of the project. - Control device via
void control(const Control &control)
with optional parameters. - You may optionally add your callback function for receive state changes notifications.
#include <Arduino.h>
#include <Appliance/AirConditioner/AirConditioner.h>
using namespace dudanov::midea::ac;
AirConditioner ac;
// Example how can change work mode easily
static inline void switchMode(Mode mode) {
Control control;
control.mode = mode;
ac.control(control);
}
// Example how can change mode and temp in same time
static inline void changeState(Mode mode, float targetTemp) {
Control control;
control.mode = mode;
control.targetTemp = targetTemp;
ac.control(control);
}
// Example how can change power state
static inline void setPowerState(bool state) {
ac.setPowerState(state);
}
// Example how can change mode to AUTO and set target temp to 25C
static inline void changeAuto25() {
Control control;
control.mode = Mode::MODE_AUTO;
control.targetTemp = 25.0f;
ac.control(control);
}
// Here you may get new properties states
void onStateChange() {
ac.getTargetTemp();
ac.getIndoorTemp();
ac.getMode();
ac.getPreset();
ac.getSwingMode();
ac.getFanMode();
}
void setup() {
Serial.begin(9600); // set serial baudrate to 9600 8N1
ac.setStream(&Serial); // set stream serial interface
ac.addOnStateCallback(onStateChange); // add callback
ac.setup();
}
void loop() {
ac.loop();
}
to the following people for their contributions to reverse engineering the UART protocol and source code in the following repositories:
If this project was useful to you, you can buy me a Cup of coffee :)