What is it?This project looks at how to hack a TV remote to control your TV, even change the channel whilst no one is looking! Infa-Red or IR is defined as having a wavelength just greater than that of the red end of the visible light spectrum but less than that of microwaves. Infrared radiation has a wavelength from about 800 nm to 1 mm, and is emitted particularly by heated objects. You cannot see infrared radiation, but you can feel it as heat energy. Infrared sensors can detect heat from the body. They are used in security lights, burglar alarms. Infrared radiation is also used to transmit data / information from place to place, including, remote controls for television sets and DVD players or to provide data links over short distances between computers or mobile phones.
1. Getting StartedThe first part of the hack is to buy an Energenie IR Remote. Energenie's Pi-mote IR board allows you to teach the Raspberry Pi any infra-red remote control and then send out the commands to control any the device. This means you can turn your Raspberry Pi into an infra-red remote for you household objects. Therefore you can control your TV, media system, iPhone Dock or even the Air Con with your Raspberry Pi.
In the LX Terminal type: sudo apt-get update sudo apt-get upgrade The Pi2 requires a few changes to enable the IR software, type sudo nano /boot/config.txt This loads the config .txt file, add the following line dtoverlay=lirc-rpi-overlay 2. Installing the SoftwareYou could reboot your Pi at this point ensuring that the IR board is connected, then once it is loaded install the software to control the IR remote.
In the LX Terminal type: sudo apt-get install lirc sudo apt-get install lirc-x Restart the Pi, not that the default GPIO pins to used when no pins are explicitly set are: input pin for received infrared signal: PIN12 - GPIO18 , output pin for transmitted infrared signal: PIN11 - GPIO17. 3. Testing the IR Receiver
Once you have installed the software and connected the IR remote, the next part of the hack is to test that the remote is working and will 'pick up' the transmission from say, a TV remote or Blu Ray controller. Grab a controller and run a quick test as root user, sudo. Firstly you need to stop the LIRC daemon and start mode2. This mode2 shows the pulse/space length of infrared signals.
Load the LX Terminal and type: sudo /etc/init.d/lirc stop sudo modprobe lirc_rpi sudo mode2 -d /dev/lirc0 This adds the correct modules to the linux kernel and then runs a program to output the mark-space of the IR signal. Point a remote control at your IR receiver and press some buttons. You should see something like this: space 16300 pulse 95 space 28794 pulse 80 space 19395 space 28794 pulse 80 4. Transmitting SignalsNow that the remote can be recognised, the second part of the hack is to transmit a control, yes transmit a control to your device. Use your Raspberry Pi to turn your TV on, change the channel or turn the volume up! Awesome. You can transmit a signal from the Pi to the any device which uses a remote control, making use of the irsend command. The LIRC package contains the irsend tool for sending infrared signals to your device, CD player, DVD player or even a robot! Firstly, there are a few alterations to make.
5. Alter the Hardware FileIn the /etc/lirc/ folder there is a file call hardware.conf there are four changes to make here. To open the hardware file and edit it,
Open the LX Terminal, type: sudo nano /etc/lirc/hardware.conf Make the following changes: LIRCD_ARGS = "--uinput" DRIVER = "default" DEVICE = "/dev/lirc0" MODULES = "lirc_rpi" Press Control X to save the file, don’t rename it, press Y and then return. Then you need to restart the lirc, type the code, sudo /etc/init.d/lirc restart. |
Hacking the TV6. New LIRC fileThe lircd.conf file contains all the key functions and codes to enable your Pi to talk to your TV, DVD player or device. You do not need to create these files as it is possible to use an existing remote control configuration file. These configurations can be found on LIRC supported remotes index: although, some are very old and do not work. Most remotes have a model number which can easily be located. Some remote configuration files will not be available on the LIRC index because not all remotes are supported by LIRC. You may have to look for more up to date files, I found some in GitHub. Download the file for your remote and save into the Pi/Home folder. (I am using a Samsung remote)
7. Configuration File #EasyOnce you have a suitable file the easiest setup method is to copy over the code in the lirc file which you found. However, this will overwrite any old configuration setup that you have. (This is only an issue if you have already set up a configuration file. Step 8 will show you how to copy and save a new file.) With this method simply open the lircd.conf file by typing ,
sudo nano /etc/lirc/lircd.conf Then copy and paste over the code in the lirc file which you found. Press Control and X to save the file, do not change the name. Then you need to restart the lirc, type the code, sudo /etc/init.d/lirc restart. If this works you can then test that the setup is correct by typing, irsend LIST Samsung " " This will list all the KEYS that are installed in the lircd.conf file. If it has worked jump to step 9 to set up your controls to interact with the TV. 8. Configuration File #HarderIf you have already setup an lirc file or you want to use a new one but keep the old one, say for another remote, then you can create a new configuration file (using /dev/lirc0) and save the output to ~/lircd.conf Firstly, make a backup of the original lircd.conf file, the one you do not wish to overwrite and are trying to save.
In the LX Terminal type, sudo /etc/init.d/lirc start sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf Then copy over the new configuration file by typing sudo cp ~/lircd.conf /etc/lirc/lircd.conf Once you’ve created your new remote configuration file save/add it to /etc/lirc/lircd.conf using the method in step 7. The original configuration file will now be saved as lircd_original.conf Finally start up the LIRC again sudo /etc/init.d/lirc restart 9. Hacking the TVOnce you have set up your remote's lirc file you are now ready to control your TV or device. This will make use of the irsend application that comes with LIRC to send the commands. The commands are very simple, irsend SEND_ONCE Remote_Name Remote_Button For example to control the TV Menu you would type in the LX Terminal, irsend SEND_ONCE Samsung KEY_MENU This will send the Menu IR signal and the menu will appear on the TV. In order to send a different button or signal all you must do is alter the last KEY_ field. These key pre-fixes can be found in the lircd.conf file.
10. Common ErrorsTransmission error
This usually means that the lircd.conf file is not correct and contains an error. For example using a file from 2007 instead of the 2014 version. Connection refused Usually means that the LIRC has failed or a the hardware changes are not correct. Check the boot.config file or the hardware.conf file then, restart the lirc sudo /etc/init.d/lirc restart Code RecapRestart the LIRC program, useful after you have changed a file such as the hardware.conf or lirc.conf: sudo /etc/init.d/lirc restart
Stop the LIRC program, useful when testing the program: sudo /etc/init.d/lirc stop Start the LIRC program: sudo /etc/init.d/lirc start List all the Keys in the file: irsend LIST Samsung "" |
- Home
- Python
- Ras Pi
-
Pi Hardware
- Pi-Hacks
-
Pi-Hacks 2
- The Joker
- Hologram Machine
- Google Vision: Camera Tell
- Yoda Tweets
- Pi Phone
- Darth Beats
- Twitter Keyword Finder
- Crimbo Lights Hack
- Xmas Elf
- Halloween 2016
- Halloween Hack 2015
- Socrative Zombie
- Voice Translation
- The Blue-Who Finder
- GPIO, Twitter
- Pi Chat Bot >
- PiGlow & Email
- Pibrella Alarm System
- SMS with Python >
- Pi-Hacks 3
- Minecraft
- Computing
- Contact Me
- Random Hacks