Linux Infrared Control Part 2: Send IR

tl;dr

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 second 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 post will be focused on sending output and depends on Linux Infrared Control Part 1: Receive IR.

Background

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. 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.

Configure Rasbpian and Lirc

Edit /boot/config.txt to add gpio pin 15 (output), this is in addition to the existing configuration for pin 14 (input) from part 1. The complete edit should look like:

Reboot to make the changes live:

Sender Hardware

Note

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

In addition to the breadboard and Male to Female jumper wires from part one (you will need 3 more wires for this circuit), you will also need:

IR transmitter LTV-4208 infrared emitter – 940NM
https://www.creatroninc.com/product/ltv-4208-infrared-emitter-940nm/
https://www.sparkfun.com/products/241
https://www.adafruit.com/product/387

220 ohm Resistor (Red, Red, Brown, Gold stripes)
https://www.creatroninc.com/product/14w-assorted-resistor-kit/
https://www.sparkfun.com/products/10969
https://www.adafruit.com/product/2780

BC547 transistor
https://www.creatroninc.com/product/bc547-npn-bjt-50v-01a
https://www.sparkfun.com/products/8928

Data sheet for BC547 transistor
https://www.sparkfun.com/datasheets/Components/BC546.pdf

Note

If you get a different transistor, check the data sheet for the transistor to make sure it is wired correctly, otherwise you can fry your components and let out the magic smoke.

Our control input flows into the base, the output is tied to the collector and the emitter is kept at a fixed voltage.

Setup the circuit on the breadboard. There are three leads to the BC547 transistor, with the flat side facing up, and should be connected as follows:

The complete circuit diagram looks like:

IR LED long leg is anode (+), towards pin 2 A
IR LED short leg is cathode (-), towards BC547 transistor

Original ASCII art from:
http://aron.ws/projects/lirc_rpi/
http://weyprecht.de/2015/11/30/raspberry-pi-ascii-art/

The wiring should look like:

Configuration For Remote Buttons

The example configuration file example.lircd.conf created in part 1 will be used to test the sender hardware. Copy the config file to /etc/lirc/lircd.conf.d/:

The configuration should look something like this:

Restart lircd.service to load the configuration:

Test Transmitter Hardware

This test will use a the example remote configuration by sending the only configured button, the KEY_POWER button. Move the circuit near the device that the remote from step 1 controlled and see if the device is powered on and off.

Alternately, most camera phones can observe IR light and can be used to view the IR led flashing.

Type the following:

If the result is nothing on the command line and device powers on or off, success!

If the result is:

Check the status to see if there are any error messages:

Summary

If you want back and capture more or all of the buttons for the remote, you can completely control the device from the Raspberry Pi.

In the next post, we will show finalized hardware design options, where the prototyped breadboard circuits are soldered together for more permanent solutions.

Comments are closed.