THINGS USED IN THIS PROJECT
Hardware components: | ||||||
|
× | 1 | ||||
|
× | 1 | ||||
|
× | 1 | ||||
|
× | 1 | ||||
Software apps and online services: | ||||||
|
STORY
Recently I have been working on a project that would allow anyone to turn a Raspberry Pi into a universal remote. To do this I have been using LIRC (LINUX Infrared Remote Control), LIRC is a package that allows you to decode and send infra-red signals to many (but not all) commonly used remote controls. This project provides a starting point for experimenting with an IR LED and the LIRC package on the Raspberry Pi and extending the basic setup with new features and functionality, such as adding an IR receiver to generate a LIRC remote profile using an existing remote control.
Step 1: Materials
Recently I have been working on a project that would allow anyone to turn a Raspberry Pi into a universal remote. To do this I have been using LIRC (LINUX Infrared Remote Control), LIRC is a package that allows you to decode and send infra-red signals to many (but not all) commonly used remote controls. This project provides a starting point for experimenting with an IR LED and the LIRC package on the Raspberry Pi and extending the basic setup with new features and functionality, such as adding an IR receiver to generate a LIRC remote profile using an existing remote control.
Step 2: Circuit
Although you can connect an IR LED directly to GPIO pins on the Raspberry Pi, the LED’s output signal will be too weak, and the IR transmitter will have a very limited range. A simple transistor circuit solves the problem by amplifying the current output from a pin and thus increasing the IR LED’s signal strength.First place your IR LED on the breadboard and wire the long leg(Anode) to 3.3 volts(pin 1) and the long leg(Cathode) to the Emitter of your transistor. Next, run a wire from ground(pin 6) to the collector of your transistor and then use a 10K resistor to connect the base of your transistor to pin 22.
First place your IR LED on the breadboard and wire the long leg(Anode) to 3.3 volts(pin 1) and the long leg(Cathode) to the Emitter of your transistor. Next, run a wire from ground(pin 6) to the collector of your transistor and then use a 10K resistor to connect the base of your transistor to pin 22. Next, place your IR receiver on the breadboard. Run 3.3 Volts to its right leg and connect its center leg to ground. Finally connect pin 23 to the left leg of your IR receiver.
Step 3: LIRC Install and Setup
First, we’ll need to install and configure LIRC to run on the RaspberryPi:
sudo apt-get install lirc
Add to your /etc/modules
file by entering the command below
sudo cat >> /etc/modules <<EOF
lirc_dev
lirc_rpi gpio_in_pin=23 gpio_out_pin=22
EOF
Change your /etc/lirc/hardware.conf
file by entering the command below
sudo cat > /etc/lirc/hardware.conf <<EOF
########################################################
# /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=""
########################################################
EOF
Edit your /boot/config.txt
by entering the command below
cat >> /boot/config.txt <<EOF
dtoverlay=lirc-rpi,gpio_in_pin=23,gpio_out_pin=22
EOF
Now restart lircd
so it picks up these changes:
sudo /etc/init.d/lirc stop
sudo /etc/init.d/lirc start