Things used in this project

Story

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.

LIRC is a software that allows you to decode and send infra-red signals of many (but not all) commonly used remote controls. Thanks to Ar0n now we can use lirc with RaspberryPi.

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_dev

lirc_rpi gpio_in_pin=23 gpio_out_pin=22

Edit /etc/lirc/hardware.conf and change it to:

LIRCD_ARGS="--uinput"

LOAD_MODULES=true

DRIVER="default"

DEVICE="/dev/lirc0"

MODULES="lirc_rpi"

LIRCD_CONF=""

LIRCMD_CONF=""

If you run an older 3.18 kernel change the /boot/config.txt file and add the following line:

dtoverlay=lirc-rpi,gpio_in_pin=23,gpio_out_pin=22

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:

#!/bin/bash

/usr/bin/irsend SEND_ONCE lg_tv KEY_POWER

sleep 10

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