Recently 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.
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 librarary 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.
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.
Note: updated to correct some minor innacuracies (22-March-2014).