Introduction: Record and Send Infrared Commands to Air Conditioner With Arduino
I had a hard time to find some easy to use code to read and send codes to my AC that I use mainly for heating.
Especially for my Daikin unit that apparently uses encrypted commands.
When I finally found this I thought I should make it easier for others to find as well.
To be able to control an AC unit we first need to record the IR commands sent from the remote. A typical AC remote will for each key-press send all settings it has.
If you press Temp+ it will actually send “Heating, 24*C, medium fan, Sensor off, on timer after 265 minutes, etc“
We want to record what the remote sends at each temperature and for each mode. Also record “OFF”. If you don’t want timers you can’t control, be sure to remove the settings for them in the remote.
Step 1: Connect Arduino to Read Codes
First you need to set the Arduino up with the components. I used a Arduino Uno and an TSOP34438 infrared receiver for 38kHz. It is connected to 5v, Gnd and Digital pin 2.
Step 2: Download Code for Reading IR Codes
The code I used is from the great people at AnalysIR: https://www.analysir.com/blog/2014/03/19/air-condi...
Code can be downloaded here: https://www.analysir.com/blog/?attachment_id=515
Connect the Arduino to computer trough USB, start the Arduino IDE and open the downloaded file.
Step 3: Reading the Codes
Upload to Arduino and open the “Serial monitor” under “Tools” menu.
It should read “Press the button on the remote now - once only”
Now you have to make sure no interference infrared light is present, darken the room so no sunlight interferes.
Angle the remote towards the infrared receiver and approximately 1m away.
Fire away a command and in a moment you should receive the command in the Serial monitor window as
“Raw: (633) 9996, -25076, 3492, -1712, 452,...”.
My remote sends 633 on/off pulses. The numbers represent time the light is on (positive number) or off (negative number). The time is in microseconds.
1 microsecond i equal to one millionth (0.000001 or 10−6 or 1/1,000,000) of a second. Because of the verry short times, no two signal will be completely equal. That's ok because 25072 and 25080 will be seen as the same value. As you can see in the screenshot here, the times differ a bit for the same command, in this case "off". The important thing is to get the same number of signals.
The positive numbers are the length of time in microseconds that the ir light is on, followed by a negative number which is the length in time in microseconds the ir light is off. 1000 microseconds = 1ms and 1000ms = 1s.
Step 4: Send IR Codes
When you have the codes, it's much easier to send them back to your AC unit.
I use a MQTT to a Particle Photon with a Keyes IR led and a modified version of the very good code at:
Download code at the end of that page.
We have a be nice policy.
Please be positive and constructive.