Linux Infrared Control Part 1: Receive IR


Would you like to use a remote control to control your computer? How about using your computer to send remote control signals to your TV or Stereo instead of using the remote?

This is the first in a series of posts where I will describe how to use a Raspberry Pi, Raspbian and Linux Infrared Remote Control (Lirc) to receive and send infrared remote control signals. This first post will be focused on setup and receiving input.


Linux Infrared Remote Control (Lirc) has been around for many years and is an example of a ‘traditional’ unix application: it can do many things and is tricky to setup (the documentation even says a much). With a Raspberry Pi and a few cheap electrical parts it is possible to create a custom remote control or have your computer respond to your existing remote.

The presence of the general purpose input output (GPIO) pins on the Raspberry pi allows the control of external circuits from a linux computer. These instructions will use Linux Infrared Remote Control (Lirc), a well established and tested collection of applications, to receive input and send output.

Raspberry Pi Models

A quick note about Raspberry Pi models. All Raspberry Pis have a row of GPIO pins, but depending on the model, some of have either 26 or 40 pins. To confuse things a little more, early models changed what some pins did.

In an attempt to keep things simple, these instructions will use the following pins which are the same across all models:

  • Pin 8 (GPIO 14) for input
  • Pin 1 for input power
  • Pin 6 for input ground
  • Pin 10 (GPIO 15) for output
  • Pin 2 for output power
  • Pin 14 for input ground


It should be noted there are two ways to refer to the pins. One way is by pin number, starting at 1, labeled on the board with P1. A second way is by pin function, such as GPIO1, TXD0 etc. FYI there are multiple GND, +3V3 and +5V pins. These instructions will be using pin numbers.

Install & Update Raspbian

Rather then re-hash how to install Raspbian on a SD / MicroSD, please see the official instructions. Use Etcher, it makes things much easier and less likely to make your computer unbootable.

Software Versions

Testing was done with 2017-09-07-raspbian-stretch-lite, which included lirc version 0.9.4c.

Different versions of Raspbian or lirc may have different results.

After installing, connect the Raspberry Pi to the internet and login.

First change your password.

Optionally enable ssh, run raspi-config:

Select Interfacing Options, select SSH, Enabled YES. Also at this point consider changing your hostname and any localization settings.

Apply all updates:

Make sure the firmware is up to date:

Reboot to make sure changes are live:

Finally, install lirc:

This installs version 0.9.4c of the lirc package.

Configure Rasbpian and Lirc

Edit /boot/config.txt to configure gpio pin 14 (input):

Edit /etc/lirc/lirc_options.conf to configure to use the Raspberry Pi GPIO pins by changing the driver from devinput to default:

Reboot to make the changes live:

Receiver Hardware


Shutdown the Raspberry Pi whenever connections are made to the GPIO pins.

First buy a breadboard, leads and infrared receiver. The receivers are cheap, around $2.00.

This hardware will be to prototype the circuit and will not require soldering.


Male to Female jumper wire

TSOP38238 infrared receiver

Setup the sensor on the breadboard. There are three leads, if you are using the TSOP38238, lens (‘bump’ on sensor) facing up and should be connected as follows:

Original ASCII art from:

The wiring should look like:

Receiver Software: Testing with mode2

Now that the circuit is complete, next step is to test the reception of remote control button presses

First stop lirc, if running:

Second, start mode2, which will listen for pulses from the sensor.

On start you should see:

Point remote at receiver, begin pressing buttons. If you see a series of lines like the following, then the circuit is working:

Press control c to exit mode2.


Receiver Software: Capture with irrecord

Next we will create a lirc configuration file for your remote.

As a result of the large number of different remotes with buttons, lirc defines a standard set of button names (commonly referred to as a namespace), the current namespace has over 500 button names. A typical remote will only have a small subset of these names.

To see the list of standard button names, type:

Based on the remote being captured, it is worth taking a few minutes and plan out which buttons names should be used.

Existing Remote Configurations

The lirc project does ship with some remote configurations already captured, see /usr/share/lirc/configs

Once captured, these button presses can be used to either send out the same button presses using an ir transmitter (sometimes referred to as a irblaster) or listen and execute programs when the button presses are received.

As a demo, we are going to capture the power button on the remote, this is the KEY_POWER in the name space. In part 2, this button press will be transmitted to demo irsend.

First stop lirc, if running:

Second, start irrecord and specify an appropriate conf filename:

On start the example output look like:



And that is it! Hopefully you have a really simple circuit that is capturing the IR signals from your remote. Next we will transmit this button press back to power on or off the device the remote controlled.

Comments are closed.