Decoding the Raw IR signal of an AC

Hello everyone,

I am new to Arduino and ESP32. Recently, I have been tinkering with an ESP32 to make a smart AC remote that can be controlled over the internet. It also features automation, such as turning the AC on or off in the presence of humans and controlling the temperature based on a sensor's readings.

I used the IRrecvDumpV3 to get IR signals from my original AC remote, and I faced no problems in doing that. I was able to capture the IR codes and use them to control the AC. However, the main problem I am facing is the size of the data. Each IR signal contains all the information, such as temperature, fan speed, and the state of the swings. Each IR signal thus consists of a lot of information, which takes up a significant portion of the ESP32's memory. To address this, I am storing the IR signals in the flash memory to conserve the more limited SRAM for other uses.

My question is: is there any way I can decode the raw IR signal to identify which part controls which parameter?

The IR signal to turn on the AC looks like this:
const uint16_t temp16ON[419] = {
9038, 4442, 700, 1618, 688, 520, 684, 520, 684, 1610, 700, 1608, 698, 1622, 686, 522, 680, 524, 684, 520,
684, 520, 686, 520, 688, 518, 686, 520, 684, 522, 684, 518, 686, 520, 684, 520, 688, 520, 686, 520, 684,
522, 684, 1618, 690, 1616, 688, 520, 684, 520, 684, 522, 684, 520, 684, 524, 684, 518, 686, 1620, 688,
520, 686, 1622, 684, 520, 688, 520, 686, 1606, 698, 520, 686, 19936, 702, 522, 686, 520, 684, 518, 686,
520, 686, 522, 684, 520, 684, 520, 686, 520, 684, 518, 686, 522, 684, 520, 684, 520, 686, 518, 688, 520,
684, 1622, 686, 1620, 684, 524, 684, 520, 684, 520, 686, 522, 684, 520, 684, 524, 682, 522, 684, 520, 684,
522, 686, 518, 686, 520, 686, 520, 688, 1620, 686, 1620, 686, 1620, 684, 1630, 680, 39962, 9024, 4454,
688, 1622, 684, 520, 686, 520, 684, 1628, 680, 1622, 684, 1622, 684, 522, 684, 520, 684, 522, 682, 522,
686, 520, 682, 524, 680, 524, 682, 522, 684, 524, 682, 524, 682, 522, 684, 520, 682, 524, 684, 524, 684,
1622, 684, 1622, 684, 520, 684, 524, 684, 518, 684, 520, 684, 520, 684, 524, 682, 1624, 686, 1622, 680,
1626, 682, 524, 688, 520, 682, 1622, 684, 522, 684, 19932, 706, 520, 684, 520, 686, 520, 682, 522, 684,
520, 684, 520, 686, 524, 682, 520, 686, 520, 684, 524, 682, 522, 682, 522, 684, 524, 684, 522, 680, 522,
684, 520, 684, 522, 682, 522, 682, 524, 684, 520, 682, 522, 684, 524, 682, 1628, 682, 520, 684, 524, 682,
524, 682, 524, 682, 522, 682, 1624, 682, 1626, 682, 1620, 688, 520, 684, 39960, 9024, 4454, 686, 520, 686,
520, 684, 1622, 684, 524, 682, 1626, 684, 520, 682, 1624, 682, 522, 684, 1624, 684, 524, 682, 522, 682,
526, 682, 520, 686, 520, 682, 522, 686, 522, 682, 522, 684, 520, 682, 524, 680, 524, 684, 522, 682, 522,
684, 520, 684, 520, 684, 520, 684, 524, 680, 526, 680, 520, 686, 524, 680, 1626, 684, 522, 682, 1628, 680,
522, 682, 1622, 684, 524, 682, 19936, 704, 526, 678, 524, 682, 524, 682, 522, 686, 522, 682, 520, 682,
524, 682, 524, 682, 526, 680, 522, 682, 526, 680, 520, 686, 520, 684, 524, 684, 522, 682, 524, 682, 524,
682, 524, 680, 524, 682, 524, 680, 524, 680, 528, 680, 524, 682, 522, 682, 526, 680, 520, 686, 522, 684,
524, 680, 1626, 682, 1624, 684, 1622, 684, 1622, 682
};
Each set of IR signals for turning on/off, changing the temperature, or controlling the swings looks similar to this. How should I decode this IR code to identify which segment controls which parameter?

Thank you for your help!

Capture different signals where you systematically change one variable at a time. Observe the differences between the data packets and use that to isolate which bit codes for which parameter. Then, using that key, see if you can figure out the encoding.

1 Like

Graph the values. Observe repetitions.

1 Like

That's the point of decoding instead of using raw signals. What AC you have?

AC packets are often quite long, decoding them manually is not something you do during your lunch break.
Just one average AC protocol, Mitsubishi, is 144 bits sent twice .So 576 raw timings . Often they are quite simple to decode, but I have experienced few times very tricky custom checksum calculations. Sometimes it's more convenient to manually "compress" raw timings to binary without decoding anything.

1 Like

I have a GREE AC

Do you want to try to understand the IR signal or to find some ready made solution?

I want to understand the IR signal

ok,
at the beginning there is header 9000high, 4500low
after that is following the code. You have bit mark 690us, 1space 1620us, and 0space 520us. in certain point of your raw there is space 20000us
These timings are probably little bit off, but it's not important fo now.

So 690+1620 means 1 and 690+520 means 0

so after header comes 1001110000000000000011000.... and so on, you extract that until 20000us space, from there on in many cases the code is just repeated, but in your case not, so you have to extract that as well.
Luckily this is very short for AC code, usually they are many times longer

Thank you for explaining i was able to convert it into binary using the logic but it would be really helpful for me if i could understand which sequence does which part like the swing, temperature, mode and etc.

You sed you want to understand the signal.
If you want to understand more or decode the whole code, you have to record many signals, changing one thing at a time. And then verify what part of the bits are changing. It's very time consuming, you have to have passion to learn.

Agreed; I'd personally use Excel/Calc to facilitate the process. It can help to visualize the differences and spot patterns. But the first labor-intensive process is to generate the dataset; with a typical A/C control, there's lots of parameters to vary. I'd start with isolating a single function/parameter (e.g. temperature) and then making the dataset for that and try to figure it out. Adding the other parameters will be easier once you've managed the first one.

1 Like

If that doesn't sound good, you have two other options. Just record few important commands, like ON,COOL,22'C,FAN3 and ON,HEAT,20'C,FAN1 and OFF,... and so on.
When you have them in binary, you are able to save them in your sketch without memory issues.
Otherwise, have a look at something already done decoding.
What you think? It's up to you. I can give a hint if you want to go lazy way.

please give me the hint thank you in advance

I was decoding many minisplit ACs (not Gree)fifteen years ago on some heat pump forum together with a Finnish guy. Have a look at his github.

There is Gree library for you to study, and that receiver sketch is done well.

1 Like

Upvote for ToniA GitHub link.

@atiiot,
But I'd say that Gree AC protocols are pretty well known and has been reverse engineered long time ago.
So rather than reinventing the wheel without any background knowledge you might take a look at already implemented library: GitHub - ToniA/arduino-heatpumpir: An Arduino library to control split-unit heatpumps over Infrared ? If you are willing to learn, it's still a great starting point. Consider it as a sort of a reference manual, instead of doing trial & error from scratch.

PS: There are a few variants of Gree protocols. Take a look at your remote P/N, those comes in a less variety rather than AC Unit models made by Gree. Not even couting how many other brands are OEM'ed by Gree. I recall that I've contributed some new model of Gree remotes to this repo long time ago. As well as a more accurate transmitter code for an ESP8266...

Read post`#7-8 :wink:
And that raw receiver has Gree already implemented..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.