[Q] Controlling Air Conditioner (A/C) using Arduino GPIO

Hello

I'm trying to build a Arduino based system that will control by Home Air Conditioner (A/C).
using Logic analyzer and IR receiver I was able to extract the code that the A/C Remote is sending of a command. (see attach files)
it seem like it is sending NEC according the following sequence:

  1. Send the Code (e.g. 0xB335A962)
  2. Send the inversion (NOT op) of the code (e.g. 0x4CCA569D)
  3. Send the Code again (e.g. 0xB335A962)

I tried to reproduce this sequence using Arduino code, but for some reason it does not work.
the circuit that I'm using it very simple, it is a 2n2222 transistor and IR LED (I tried 2 type of LED: TOIR-30 and "Super-bright 5mm IR LED - 940nm" from Adafruit)
my circuit schematics is also attach.

using logic analyzer I compare the output on the GPIO and it seem like the signal on the IR receiver

I tried to send the codes using IRRemote lib that I found and also the example from the EEVBLOG, both didn't work for me.
the source code that I tried:

I'm stuck... I really need some advices and ideas

Thanks in Advance :smiley:

Is the LA trace from your Arduino IR tx or the AC remote?
If you place it on the IR receiver output you will definitely get an idea of how long the signal is and the format.

Based on what I seen have posted for AC remotes they are typically much much longer than 32 bits. The ones I have seen tend to send the full configuration every time.

So maybe IRremote is just giving you the first 32 bits of a much longer sequence?.

In the standard version of IRremote there is a limit on the number of bits.

If you search the IRremote blog you will see examples where people have extended it to cater for longer signals.

You could also try the RAW (dump) mode to see how long the signal is. You may also need to increase the buffer size (see blog)
And then once you get the full RAW output you can use this again to send a long signal using RAW.

If you do get the RAW output post it & I will have a look at it.

Which Arduino pin is the IR out going to the Transistor base?
Did you confirm your IR tx is working using a digital camera?

Thanks for the answer.

AnalysIR:
Is the LA trace from your Arduino IR tx or the AC remote?
If you place it on the IR receiver output you will definitely get an idea of how long the signal is and the format.

This Trace is on IR receiver that I hooked up, the measurement is on the out pin.
and I transmit a command from my original A/C remote.

Based on what I seen have posted for AC remotes they are typically much much longer than 32 bits. The ones I have seen tend to send the full configuration every time.

So maybe IRremote is just giving you the first 32 bits of a much longer sequence?.

In the standard version of IRremote there is a limit on the number of bits.

If you search the IRremote blog you will see examples where people have extended it to cater for longer signals.

according to what I see in the LA it is the same code that I'm getting from IRremote

You could also try the RAW (dump) mode to see how long the signal is. You may also need to increase the buffer size (see blog)
And then once you get the full RAW output you can use this again to send a long signal using RAW.

If you do get the RAW output post it & I will have a look at it.

I did new capture of the A/C original remote signal on the IR receiver (I attached the signal trace)
Here the raw data of that signal:

Decoded NEC: B335A962 (32 bits)
Raw (68): 15946 8450 -3350 650 -1550 600 -450 650 -1500 650 -1550 600 -450 650 -400 650 -1550 600 -1550 650 -400 650 -450 600 -1550 650 -1500 650 -450 650 -1500 650 -400 650 -1500 650 -1550 650 -400 650 -1500 650 -450 650 -1500 650 -400 650 -450 650 -1500 650 -400 650 -1550 600 -1550 650 -400 650 -450 600 -450 650 -1500 650 -400 650

Which Arduino pin is the IR out going to the Transistor base?

I'm using Pin 3

Did you confirm your IR tx is working using a digital camera?

yes

I imported & ran your signal thru our AnalysIR and it doesn't appear to be a 'Pure' NEC code. Even if I turn the sensitivity/tolerance up to the max it is not decoded as NEC.
There are several differences, most of which could fall within acceptable tolerances except the initial header/space.
IRremote is designed to get the signal using a lot of tolerance, which is why it is saying NEC.

In NEC the signal starts with a mark of 9,000 usecs & a space of 4,500 usecs. (Total = 13,500 usecs)
In your AC signal it is a mark of 8450 usecs & a space of 3350 usecs. (Total = 11,800 usecs)

The ones and zeros are: (totals for mark+space for each bit)
Total 1,100 usecs (vs NEC 1,120) which is close enough.
Total 2,150 usecs (vs NEC 2,250) just within limits

There is another library IRLib which is a rewrite of IRremote and the Author says it is easier to add new protocols. Might be worth checking it out.

As you can see, it is probably based on the NEC protocol but contains some slight deviations, as above.

So, if I am correct, you have 2 options:

  1. Only use the RAW mechanism to send signals.
  2. Change the definitions in the IRremote library for the NEC protocol to match the mark/space durations of your captured AC signal - or if you are competent just add a new protocol into the library (not too difficult if you know what you are doing)

Based on a quick review of your LA trace it looks like you are right, it sends CMD+inverted CMD+CMD as an error check, which in itself is a clue to it not being Pure NEC. Also if you think about it, the manufacturer would want to make sure there was no chance of accidently being activated by a standard TV remote using NEC.