Introduction: Add Infrared Interface to Your Raspberry Pi GPIO

About: Systems Administrator and Software Programmer.


I have many remote controls lying around. Some of these remote controls are no longer used because the appliance they controlled have gone kaput and were thrown. I was wondering whether the remote controller can communicate with Raspberry Pi. In addition, I do not want a USB based infrared because the special thing about Raspberry Pi is its GPIO. Therefore, it is a big pity not to use the GPIO. After completing this instructable, the next logical thing to do is to try "Install and Configure Linux Infrared Remote Control (LIRC) Software".


This instructable will show the following:
1. Install the infrared receiver diode in the Raspberry Pi GPIO pins
2. Install and configure kernel module for the infrared receiver diode

This instructable will NOT show:

  1. Install and configure Linux Infrared Remote Control software
  2. Use the infrared interface and remote control to do useful stuff.

The above is covered in my other instructables.

Target Users

Raspberry Pi users running Raspbian OS

Works for Raspberry Pi B and Raspberry Pi 2

Step 1: Install Raspbian OS

Follow the steps in

Step 2: Buy the Parts

Step 3: Install the Infrared (IR) Receiver Diode

Power off Raspberry Pi.

Use three jumper wire of different colour.

Attach each wire to each leg of the IR Receiver diode.

Attach the other end of the jumper wire to the Raspberry Pi by following the adafruit's Infrared tutorial

Step 4: Install and Configure Kernel Modules

Install the Infrared (IR) Receiver kernel module

sudo modprobe  lirc_rpi

Check that above kernel module is loaded

sudo lsmod | grep lirc_rpi 
lirc_rpi                7498  0 
lirc_dev               10391  1 lirc_rpi

We should find a line in dmesg that says:

sudo dmesg
lirc_rpi lirc_rpi.0: lirc_dev: driver lirc_rpi registered at minor = 0 [68648.951805] lirc_rpi: driver registered!

Check that Linux has created a device file to represent the infrared device hardware.

sudo ls -l /dev/lirc*

crw-rw---T 1 root video 247, 0 Jan 27 15:28 /dev/lirc0

The IR Receiver device file is /dev/lirc0.

If the above device file does not exist, the installation of the infrared receiver diode hardware has FAILED.

In my Raspberry Pi, I have to reload theInfrared (IR) Receiver kernel module after ever reboot. To aviod manually reloading and make the IR Receiver kernel module persistent across reboots, add an entry to the module file.

On the terminal emulator:

vi /etc/modules

Append the following to the file:



The licr_rpi module STOPPED working after I updated my Raspbian's kernel. After googling. the following method solved the issue:

Add the following to /boot/config.txt:


Remove the lirc_rpi in /etc/modules

Refer to the source for more details