Controlling HVAC over the Internet

I was interested in the smart home topic for a while and finally the first actuator is operation in my flat. I’ve already had sensors and I processed the data coming from them using a Raspberry PI and RRDTool which was spectacular.

Inside/Outside temperature

During a heat wave in the summer the need arose for controlling the HVAC remotely. When I finish at work I simply turn on the device and when I arrive at home it’s already nice and cold. I could not find any solution for this so I started reverse engineering the controlling of the HVAC.

First I measure the remote controllers LED signals with an oscilloscope. It used the regular 38kHz carrier. After this I connected a 38kHz infrared receiver to my Raspberry and I installed LIRC. I made a simple software that created a histogram of the pulse width values. It turn out that the header starts with a 3525ms long pulse and an 1575ms long space and the data bits are using 525ms long and 110ms short periods. The data bits always starts with a short pulse follewed by a short or long space depending on the bit’s value.

I was able to receice bytes after finding the parameters above so I started to push all the buttons on the controller. The remote always send it’s whole state (except stepping the timer) so after half our my code was ready.

enum OperationMode {
    Heat = 0x1,
    Dry = 0x2,
    Cool = 0x3,
    Fan = 0x7,
    Auto = 0x8,
};

enum FanSpeed {
    AutoFan = 0x0,
    Sleep = 0x1,
    Low = 0x2,
    Medium = 0x3,
    High = 0x5
};

enum Swing {
    Forward = 0x1,
    AlmostForward = 0x2,
    Middle = 0x3,
    AlmostDownward = 0x4,
    Downward = 0x5,
    AutoSwing = 0x7
};

union Packet {
    struct Bits {
        uint8_t preamble[5];
        
        uint8_t reserved1 :2;
        uint8_t on :1;
        uint8_t offTimerEnable :1;
        uint8_t onTimerEnable :1;
        uint8_t reserved2 :3;
        
        uint8_t operationMode :4;
        uint8_t reserved3 :4;
        
        uint8_t temperature :4;
        uint8_t reserved4 :4;
        
        uint8_t fanSpeed :3;
        uint8_t swing :3;
        uint8_t reserved5 :2;
        
        uint8_t offTime :8;
        uint8_t onTime :8;
        
        uint8_t ending[2];
        uint8_t checkSum;
    } bits;
    uint8_t raw[14];
};

I quickly created a code that sends these packets over IR and finally I was able to control my air conditioner. The first UI was SSH from my phone.

MQTT

As a further development I created an MQTT broker (with proper encryption and authentication) and it made a bit easier to control the thing because there are many applications for Android (like MQTT Dash) that can create simple MQTT control UIs. My goal is to wire all my sensors and devices into MQTT and create a special app for this as well.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top