Controlling your TV or any infrared device with a Raspberry Pi

Although the Internet of Things is relatively new, controlling devices remotely is as old as sin; devices have been using IR remotes for ages. There is a lot of untapped potential from the infrared devices sitting in your home. Besides the raspberry pi, you can get all of the materials for this project at your local electronics store or radioshack. To unlock this potential you need the following parts:

  • A raspberry pi (Any model OK)
  • A PNP Transistor
  • One infrared LED/Blaster
  • One infrared receiver (optional)
  • Various resistors (10kΩ, 37Ω)

Controlling your TV or any infrared device with a Raspberry Pi

Hardware

The hardware required for this project are all basic components that you can pick up locally. The schematics are provided below, followed by descriptions of each part.

IR Blaster

The infrared blaster consists of a IR LED, 37Ω/10KΩ resistor, and a PNP transistor.

Because the GPIO of the raspberry pi can only handle 50mA maximum, and our LED wants to use 100mA, we will power the IR LED using a PNP transistor and the 5V power supply instead.

Connect the IR LED in series from the 5V pin on the Raspberry pi through a 37Ω current limiting resistor to the collector of your PNP transistor (top side in the diagram below, the line in the schematic represents the flat side of the transistor package.) The resistor ensures that the LED will never exceed its 100mA rating. Hook the emitter (bottom) directly to ground.

The base of the transistor is what will be used to switch the transistor on and off. Connect it through a 10KΩ resistor to GPIO 22.

IR Receiver

The infrared receiver is optional, and is only required if you cannot find your remote already in the LIRC Remote Database. The receiver is connected to ground and 3v3 from GND and Vcc respectively. The Data pin on the receiver should be connected to GPIO 23.

Because the GPIO varies slightly between raspberry pi models, please check out this GPIO reference guide to find exactly which pin to connect to.

Installing necessary software on the pi

LIRC

Please note that I borrowed heavily from alexba.in in this section. Essentially, this section is his tutorial boiled down

LIRC stands for Linux Infrared Remote Control. The acronym speaks for itself, really. With almost no work, this package allows you to record and play back from any infrared remote control.

If you do not already LIRC installed, run the following command on your pi:

sudo apt-get update && sudo apt-get install lirc

Next, we have to fix the configuration of lirc for your pi. Modify /etc/lirc/hardware.conf to match alexba's below using your nano /etc/lirc/hardware.conf or your favorite text editor.

Controlling your TV or any infrared device with a Raspberry Pi schematic

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
########################################################
# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS=”–uinput”
# Don't start lircmd even if there seems to be a good config file
# START_LIRCMD=false
# Don't start irexec, even if a good config file seems to exist.
# START_IREXEC=false
# Try to load appropriate kernel modules
LOAD_MODULES=true
# Run “lircd –driver=help” for a list of supported drivers.
DRIVER=”default”
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE=”/dev/lirc0″
MODULES=”lirc_rpi”
# Default configuration files for your hardware if any
LIRCD_CONF=””
LIRCMD_CONF=””
########################################################
view raw hardware.conf hosted with ❤ by GitHub

Next, run these commands to finish setting up the pi and restart LIRC.

 

For more detail: Controlling your TV or any infrared device with a Raspberry Pi


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top