Overview
This tutorial will explain how to use an infrared remote control to remotely operate the video center installed on the Raspberry Pi.
Before you start, you need to follow this tutorial to build your Raspberry Pi as a video center.
required parts
After building the AV center, you need to buy some parts.
name | quantity | |
|
Infrared sensor |
1 |
|
Infrared remote control |
1 |
|
Female to Female Dupont Wire |
1 |
hardware connection
The infrared sensor has only three leads, all of which need to be connected to the GPIO pins of the Raspberry Pi. We need to use a female-to-female Dupont wire to connect them. A good Dupont wire connected to the infrared sensor will make the connection more reliable.
Make the connections as shown below. The color of the jumper wire doesn't matter, it's just that the colors are easier to tell apart.
Note that using the IR sensor on the Raspberry Pi requires 3.3V, never use 5V.
LIRC
The communication between the Raspberry Pi and the remote control is done through LIRC (Linux Infrared Remote Control). Most Raspberry Pi distributions are already pre-installed, so on Rasbmc we don't need to install it, just do some settings. .
In order to ensure that the infrared hardware is working properly, we can use SSH to connect the Raspberry Pi with XBMC installed to test it.
If you have never used SSH, please see this tutorial.
In the system information interface of XBMC, we can get the IP address of the Raspberry Pi.
We need to turn off the infrared function, otherwise we can't use LIRC via SSH. Go to the XMBC settings interface, and set the " Enable GPIO TSOP IR Receiver" option to disabled.
Remember to restart after making changes.
Then use SSH to connect to the Raspberry Pi and execute the following command:
Now operate the remote in front of the IR sensor, each key press should display a set of 'pulse' / 'space' messages.
Congratulations! The infrared sensor is working fine.
Configure and test
We already know that the IR hardware is OK, we need to give LIRC a configuration file to define the buttons on the remote.
Through an SSH session, execute the command:
nano lircd.conf
Paste the following into the file, press CTRL-x to exit, and Y to confirm.
# Please make this file available to others
# by sending it to <[email protected]>
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Thu Mar 14 14:21:25 2013
#
# contributed by
#
# brand: /home/pi/lircd.conf
# model no. of remote control:
# devices being controlled by this remote:
#
begin remote
name /home/pi/lircd.conf
bits 16
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 8945 4421
one 594 1634
zero 594 519
ptrail 598
repeat 8949 2187
pre_data_bits 16
pre_data 0xFD
gap 106959
toggle_bit_mask 0x0
begin codes
KEY_VOLUMEDOWN 0x00FF
KEY_PLAYPAUSE 0x807F
KEY_VOLUMEUP 0x40BF
KEY_SETUP 0x20DF
KEY_UP 0xA05F
KEY_STOP 0x609F
KEY_LEFT 0x10EF
KEY_ENTER 0x906F
KEY_RIGHT 0x50AF
KEY_KP0 0x30CF
KEY_DOWN 0xB04F
KEY_BACK 0x708F
KEY_KP1 0x08F7
KEY_KP2 0x8877
KEY_KP3 0x48B7
KEY_KP4 0x28D7
KEY_KP5 0xA857
KEY_KP6 0x6897
KEY_KP7 0x18E7
KEY_KP8 0x9867
KEY_KP9 0x58A7
end codes
end remote
This configuration file should be placed in the home directory of the user pi.
Now, go back to the XMBC settings interface and enable the " Enable GPIO TSOP IR Receiver" option. Then set the " GPIO IR Remote Profile" as shown below:
Restart XMBC, and a prompt box like the one below should be displayed in the lower right corner when it is turned on.
The remote control should work normally, no more mouse and keyboard to control XMBC, oh!
Using another model of remote control
I am using a tool 'irrecord' in LIRC to generate remote configuration files.
If you want to use other remotes, you can use this tool to generate configuration files.
Proceed as follows:
Turn off the " Enable GPIO TSOP IR Receiver" option in XMBC .
Change the current lircd.conf file to a different name.
Enter the command 'irrecord --list-namespace'. The parameter indicates that the available key names will be prompted.
Enter the command 'irrecord -d /dev/lirc0 ~/lircd.conf'
Just follow the instructions. The program will automatically calculate the duration and code of the remote control.