Do you want to controls your TV, DVR and more using RaspberryPi?
In this chapter I will explain how can we control a TV or almost everything that uses an infrared remote control using Raspberry. This is part of my Home Automation project.
But before that, we need to connect some parts that are capable to send and receive/decode IR signals.
If you want to send IR data then you will need a IR Led.
First install Lirc:
sudo apt-get install lirc
Then edit /etc/modules and add the following (if you use another GPIO pin then change the lines):
lirc_rpi gpio_in_pin=23 gpio_out_pin=22
Edit /etc/lirc/hardware.conf and change it to:
If you run an older 3.18 kernel change the /boot/config.txt file and add the following line:
Reboot Raspberry Pi in order to apply changes.
Connect the IR Led. I used the following schema:
- Q1 = BC547 it’s a transistor used to give the IR led enough power.
- R1 = 220ohm
- R2 = you can skip this
- 940nm IR LED 40deg
After you have installed and configured Lirc for RaspberryPi, the first thing to check is if your TV is in Lirc Database. In my case I am able to control: My LG TV, Microlab Audio system
For starting TV and then MUTE I created a small script:
/usr/bin/irsend SEND_ONCE lg_tv KEY_POWER
/usr/bin/irsend SEND_ONCE lg_tv KEY_MUTE
Then I created in RController a new command. This way when I get home, I can turn on TV from my phone, dim lights and set an ambient atmosphere to enjoy my movie.
I created a small script that runs via cron on my RaspberryPi and checks if current time is past 7 PM and if I am at home (it will search for my phone by ping). If it is past 7PM and I am arriving home, it will turn on lights and TV.
Source: IR remote with Raspberry PI
Current Project / Post can also be found using:
- 940nm ir led light raspberry pi