Raspberry Pi 3 running MythTV

By | January 20, 2017

MythTV Frontend running on Raspberry Pi 3

I have a MythTV server running. It’s been up and going for 7 years now. It handles all of our TV and Movies. It is setup in our living room and works great. Recently, we decided to setup a TV in our bedroom and wanted to access live TV, our recorded shows and all of our DVDs. The odroid c2 and the raspberry pi 3 (plus the decoder/license keys) fit the bill just nicely. The odroid c2 has a built-in IR device where the raspberry pi 3 does not. I had to use the built-in GPIO along with an IR receiver to get a remote to work properly with the pi 3.

I’m writing this simply because the documentation on setting everything up is a little out-dated. I encountered a few differences setting things up and wanted to share.

I installed the main Raspbian image (Raspbian Jessie with PIXEL) from 2016-11-25. Then I added the MythTV Light repository for the raspberry pi. https://www.mythtv.org/wiki/MythTV_Light

From that page, I created a repository entry in /etc/apt/sources.list.d and called it mythtv.list. The contents are as follows:

# MythTV Light for Raspberry Pi
deb http://dl.bintray.com/bennettpeter/deb/ jessie myth28

I saved the file and then updated my software with an apt-get update and then proceeded to install with an apt-get install mythtv-light.

Once I got the software installed, I configured my frontend to connect to my backend server and everything was functioning properly. I used this site, https://www.mythtv.org/wiki/Raspberry_Pi, as a reference for configuration. I set the TV Playback to use the OpenMAX High Quality profile. For audio playback over the HDMI cable to my TV, I chose Alsa:Default. I did not tweak the sound card configuration file to enable AC3 or DTS playback.

I had to get my IR receiver created now, before I could set it up. This part was very simple. I followed the great guide from adafruit (https://learn.adafruit.com/using-an-ir-remote-with-a-raspberry-pi-media-center/configure-and-test?view=all) on how to create the IR receiver. They sell all the parts needed and it was very simple to do. You simply locate the proper GPIO pins on your raspberry pi and connect the wires from the pi to the IR receiver. Once I confirmed mine was working (in the steps later on), I used electrical tape to secure the IR receiver. You could solder the wires to the IR receiver if you wanted to, but I opted not to do that. I may in the future though.

Now, I’m ready to setup the IR receiver. I started off with this site, which got me going pretty good. https://www.hackster.io/duculete/ir-remote-with-raspberry-pi-d5cf5f
However, not all the information was accurate.
I installed lirc.

apt-get install lirc

I had to enable the lirc module on the pi at bootup. The OpenELEC distribution has a nice write up on configuring the pi for use with lirc. http://wiki.openelec.tv/index.php?title=Guide_To_lirc_rpi_GPIO_Receiver
To summarize, I had to edit my /boot/config.txt file and add in this line to enable it.

dtoverlay=lirc-rpi

No other settings were needed because I decided to use the default GPIO pin that lirc uses. The default is GPIO 18 (which is pin #12 on the rpi3). If you need to use a different GPIO pin, then check out this page for some more info on how to do it. http://wiki.openelec.tv/index.php/Config.txt

Next, I needed to finish setting up the lirc hardware configuration file. I noticed the default hardware.conf file was missing a few settings. I do not recall what they are, so you will have to check your own file against what I put in mine. I know I added in the REMOTE line, even though it is not really needed.

# /etc/lirc/hardware.conf
#
#
REMOTE="GPIO Remote"
# Arguments which will be used when launching lircd
LIRCD_ARGS=""

#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=””

After I saved, I rebooted my pi so I could start testing out the receiver. Once rebooted, I opened up a terminal window and tested that the IR receiver was working before I created the remote configuration file.

To test the IR, I just entered mode2. Then I started pressing buttons on my remote. If you get a response/output, then your remote is working properly and you can proceed to creating the configuration file. If not, then you will have to figure out what is wrong with your IR receiver.
You can kill/exit out of mode2 and proceed to record.

To record, you need to issue this command:

irrecord -d /dev/lirc0 lircd.conf

This will save the configuration file in the current directory and use the /dev/lirc0 device to record.
There will be instructions on the screen to guide you through configuring the buttons. You just need to type in the button name and then press the button when instructed. When you finish, you will have a configuration file that contains all the buttons for your remote.

You will want to copy this file to the /etc/lirc/ directory and replace the existing /etc/lirc/lircd.conf file with the one you just created. Once you do that, restart lirc (service lirc restart).

Now, test your configuration file by running the following command:

irw

After you run it, it will just sit and wait for button presses. Start pressing buttons and you should see the name of the button appear on the screen. If you do, you are configured properly. If not, you need to determine what is wrong.

The last thing to do, is to associate MythTV Frontend commands to buttons on the remote. Take a look at MythTV’s Keybindings page (https://www.mythtv.org/wiki/Keybindings) for a list of the main keybindings and their recommended bindings for a remote.
The MythTV Frontend binding file is stored in ~/.mythtv/lircrc
You need to edit this file and associate the remote button with the command. Here’s an example of one entry. This entry associates the remote control button, KEY_INFO, with the I key to display the info window inside the frontend.

begin
remote = RCA_Universal
prog = mythtv
button = KEY_INFO
config = I
repeat = 0
delay = 0
end

You need to repeat this entry format for each button on the remote. You should change the remote line to match the name of your remote. I named my remote (this is set inside the /etc/lirc/lircd.conf file) RCA_Universal. The only lines you need to change in this grouping (once you change the remote control name), is the button and config line.
Here’s my complete lircrc file:

# For RCA Universal Remote

begin
remote = RCA_Universal
prog = mythtv
button = KEY_INFO
config = I
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_MENU
config = M
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_HOME
config = S
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_LEFT
config = Left
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_UP
config = Up
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_DOWN
config = Down
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_RIGHT
config = Right
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_OK
config = Return
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_CHANNELUP
config = Z
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_CHANNELDOWN
config = Q
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_1
config = 1
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_2
config = 2
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_3
config = 3
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_4
config = 4
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_5
config = 5
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_6
config = 6
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_7
config = 7
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_8
config = 8
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_9
config = 9
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_0
config =
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_BACK
config = Escape
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_REWIND
config = PgUp
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_PLAY
config = P
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_FORWARD
config = PgDown
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_RECORD
config = R
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_STOP
config = O
repeat = 0
delay = 0
end
begin
remote = RCA_Universal
prog = mythtv
button = KEY_PAUSE
config = P
repeat = 0
delay = 0
end

Once you have created and updated your lircrc file, save it and then start up MythTV Frontend. You should now be able to use your remote with MythTV. By default, lirc should be enabled inside MythTV. It was for me and I did not have to change or update anything in my frontend.

To get MythTV Frontend to start automatically at boot, I used this site as a reference: http://www.raspberrypi-spy.co.uk/2014/05/how-to-autostart-apps-in-rasbian-lxde-desktop/

What I had to do was modify this file: ~/.config/lxsession/LXDE-pi/autostart
You need to add @mythfrontend to the file start mythfrontend.
Here’s what my autostart file looks like:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@mythfrontend

That starts my mythfrontend automatically whenever my pi boots up.

I made a few extra tweaks to the desktop environment on my pi3 to minimize the look of it before mythfrontend starts. I set the panel at the top to autohide. I also set my wallpaper to match the wallpaper of mythfrontend so there was not much of a difference when the desktop appears to when mythfrontend starts.

Hope this helps get you going.

Leave a Reply

Your email address will not be published. Required fields are marked *