Air Conditioners: Recording long Infrared Remote control signals with Arduino

hRecently we have been helping several members on the Arduino forum to record and playback their remote control signals from their Air Conditioners. These signals are typically much longer than those of TVs or common media devices. The 2 most popular libraries for Arduino, IRremote & IRlib are excellent, but have some limitations which we have covered in a previous post. In this post we address one particular issue that is proving challenging to users.

airconremote
Long Infrared signals prove challenging for Arduino users

The Problem: The IRLib library uses a an 8-bit byte value to manage the number of the marks and spaces of an IR signal. This means that the maximum length of a signal recorded can be up to 255 marks and spaces or circa 126 bits. This is sufficient for a reasonable number of Air Conditioners, which is great. However, both libraries also define a constant to limit the maximum number of recorded mark & spaces to 100, which effectively excludes most Air Conditioners. I suspect this is to allow sufficient SRAM available for the remainder of a user’s sketch, which makes sense.

So the first obstacle these unfortunate users experience is the ‘100 RAWBUF limit’. It is possible to circumvent this limit by increasing the value of ‘RAWBUF’  in the range of 230->255 within the library itself. This fixes things for at least 50% (our guesstimate) of Air Conditioners. The problem for the remainder of users is that their Air Conditioner uses a signal which is longer than 255 marks & spaces and it is not possible to record these signals with the libraries as currently designed. To be fair, the authors are most likely aware of this limitation and have decided to design for the majority of users.

However, the problem remains – how to record these long signals and not run out of available SRAM, with the library included. We have recently enhanced the AnalysIR firmware which allows recording very long signals and automatic code generation in ‘C’ for both IRLib & IRremote users. This firmware is currently only available to those who have a registered copy of AnalysIR.

The Solution: Today, we have decided to make a sketch available which will allow users to record very long IR signals with up to 800+ marks & spaces and output them in a format similar to IRremote’s dump output. Users can then take these timings and build a ‘sendRaw’ command using either library to replay their signal. (Please refer to the website for  each library for instructions on how to send RAW signals – links below)

As a thank you to the Arduino community  for ongoing inspiration, we are making this sketch freely available . The only restriction is that AnalysIR must be credited in any source code or derivative along with a link to this blog. We would also appreciate a link from your website, blog or forum.

UPDATE Nov-29-2014:
In case you experience issues with this script, please read the following:
Arduino Yun & Leonardo have INT0 on pin 3 instead of pin 2 as in the sketch. So just connect the IR receiver to pin 3 on the Yun or Leonardo.     🙂

UPDATE Aug-22-2017:
In case you experience issues with this script, please read the following:
Arduino Mega1280/2560 have INT0 on pin 21 instead of pin 2 as in the sketch. So just connect the IR receiver to pin 21 on the Arduino Mega1280/2560.     🙂

UPDATE May-12-2019:
Updated sketch for attach & detach interrupt function to use digitalPinToInterrupt. This will help support more Arduino Platforms. Note the pin you select must support Arduino Interrupts.    🙂

For any other platforms, please adjust the firmware as appropriate.

A copy of the sketch may be downloaded here.

If you found this article or sketch useful, leave a comment below or share via social media.

 Get your own copy of AnalysIR or check out our latest range of MakeIR module for remote control in our webshop.

External Links:
IRLib
IRremote

2 thoughts on “Air Conditioners: Recording long Infrared Remote control signals with Arduino

Leave a Reply