Using the Device

Installing Software

Of course you are free to develop your own software to use with this board. However, it was specifically designed for use with IRLib2 which is available on GitHub by clicking the green button below.

That library cannot be installed using the Arduino Library Manager. You have to install manually. Installation of the IRLib2 library is as follows:

  1. Visit the IRLib2 page on GitHib.
  2. Select the “Download ZIP” button, or simply click this link to download directly.
  3. Uncompress the ZIP file after it’s finished downloading.
  4. The resulting folder should be named "IRLib2-master" and will contain 5 separate folders. That is because IRLib 2.x is actually a collection of 5 libraries that work together. Sometimes in Windows you’ll get an intermediate-level folder and need to move things around.
  5. Copy all five folders into your Arduino library folder alongside your other Arduino libraries, typically in your (home folder)/Documents/Arduino/Libraries folder. Libraries should not be installed alongside the Arduino application itself.
  6. Re-start the Arduino IDE if it’s currently running

This repository consists of a total of five libraries each of which must be in your arduino/libraries/ folder. So for example it should be installed as follows…

  • arduino/libraries/IRLib2
  • arduino/libraries/IRLibFreq
  • arduino/libraries/IRLibProtocols
  • arduino/libraries/IRLibRecv
  • arduino/libraries/IRLibRecvPCI

Do not install them in a single folder such as this…

  • arduino/libraries/IRLib2_master
    • IRLib2
    • IRLibFreq
    • IRLibProtocols
    • IRLibRecv
    • IRLibRecvPCI

Here is a tutorial that walks through the process of manually installing libraries that are not available through the library manager.

After you have installed the library, look in the IRLib2/manuals folder. You will find an extensive set of documentation for the library in EPUB e-book format, PDF format, and Microsoft Word .docx format. Section 2 of that manual is a tutorial on the basic use of the library. Below you will find some brief explanation of how to use a board but for complete details you should really use the examples in section 2 of the IRLib manual.

Receiving Example

Start by connecting your "Recv" pin on the IR breakout board to a pin on your Arduino that is capable of handling pin change interrupts. Load the dump.ino example from the examples folder and make sure that it is configured for your input pin. Upload the program and open the serial monitor.

Then point a TV remote or other infrared remote control at your board and press a button.

Here is an example of what I saw when I pushed the play button on the remote for my Sony DVD player.

Download: file
Ready to receive IR signals

Decoded Sony(2): Value:58BCA Adrs:0 (20 bits) 
Raw samples(42): Gap:65300
Head: m2400 s600
0:m600 s650 1:m1150 s650 2:m550 s650 3:m1200 s650 
4:m1150 s700 5:m500 s700 6:m550 s650 7:m550 s650 
8:m1150 s700 9:m550 s650 10:m1150 s650 11:m1200 s650
12:m1150 s650 13:m1200 s650 14:m550 s650 15:m600 s600

16:m1200 s650 17:m550 s650 18:m1200 s650 19:m550
Mark min:500 max:1200
Space min:600 max:700

This tells us that it decoded the Sony protocol, which is protocol 2. A binary representation of the code in hexadecimal is 58BCA. Some protocols also make use of another piece of data, which we call "Address" but in this case, Sony does not use that field. It also tells you that this is a 20 bit version of the Sony protocol. Some protocols have varieties of different numbers of bits while others always use a fixed number of bits.

When a signal is on, it is called a "mark". The empty interval between signals is called a "space". After saying that it received 42 samples of marks and spaces, it says there was a gap of 65300 µs. This is the amount of time from the previous signal to the start of this signal. Most of the time you simply ignore that gap, although there can be rare instances where it's useful information. Sometimes you want to know the amount of space between frames of data.

Most protocols begin with a header which consists of an abnormally long mark and space. In this case it had a mark of 2400 and a space of 600. Next comes the actual data bits, each consisting of a mark and a space. The timing values for these marks and spaces are given. Note that bit 0 has 600, 650 followed by bit 1 which has a mark of 1150 and a space of 650. If you look at each bit, some have marks and spaces that are nearly equal to one another while others have marks which are approximately twice the normal value but spaces that are still in the range of 600 or so. Interpret each of those long marks as being a binary "1" and each of them with nearly equal length marks and spaces as a binary "0". If you do the math and convert them to hexadecimal you will get the value 58BCA which is what is reported.

This means that hexadecimal value is a compact or encoded way of representing all of that timing data. You can then use that hex value to later re-create the same signal because we know how the Sony protocol works. While Sony encodes its bits using a long marks and equal length spaces, most protocols are the opposite and use constant marks and variable length spaces. And again, other protocols use even more complicated systems of representing zeros and ones that are not quite as easy to interpret by just looking at the numbers.

After all of the data bits have been printed, it also prints some other information that can be useful in analyzing unknown protocols.

Sending Examples

Load up record.ino example program from the IRLib2/examples folder. It will do most sending and receiving, so make sure that you have your LED pin connected to an appropriate PWM output pin and your Recv pin connected to an appropriate input pin. Compile and upload the sketch and open the Arduino IDE serial monitor.

Point a remote control device and hit a button. It will record the signal. Then, anytime you send a character to the serial monitor, it will replay that signal. Here is a sample where I pointed the control for my Samsung TV that uses the NECx protocol.

Download: file
Send a code from your remote and we will record it.
Type any character and press enter. We will send the recorded code.
Type 'r' special repeat sequence.
Received NECx Value:0xE0E0F00F
Sent NECx Value:0xE0E0F00F

Every time I enter a character into the serial monitor and press enter, it would turn the TV off and on.

If you have an additional TSOP device and connect it to another Arduino, you could run the dump example on the second Arduino and this example on the first one. You would see that it is transmitting the same thing that you initially sent. If you have 2 Arduino's: one set up to send in the other to receive, it is recommended you try out the pattern.ino example. It sends a pattern of bits on a variety of protocols - you should see the same thing on the receiving end as you did on the sending end. Note, however, that some of these protocols run at 57 kHz and your TSOP device may not be able to read them. Specifically, the third example of protocol 3 which uses 57 kHz as well as protocol 5 which also uses 57 kHz.

Frequency Detection

As mentioned previously, the TSMP58000 device is used to measure the frequency of a received signal. Check out the freq and dumpFreq examples in IRLib2/examples folder as well as section "2.2.7 Advanced Receiving Examples" in the users manual for IRLib2.

The documentation IRLib2 is quite extensive and are more examples in the examples as well as in the documentation. You can find lots of answers your questions there.

This guide was first published on Aug 25, 2019. It was last updated on Aug 25, 2019.
This page (Using the Device) was last updated on Jul 14, 2020.