Hello guys, this is my guide to an OSMC-Control-Panel, which allows you to control your music with your easy-to-build Control-Panel. After you built it, you're able to Play/Pause a song, let the previous or the next song play and even change the volume up and down.
This is a private project shared for everyone who wants to build a Mulitmedia-Device for your living room or anywhere else. You need at least a little knowledge about electronics.I used a Windows Computer during the project. It is not tested for Mac in Linux system. Most of the time the downloadable software can be used on Mac, too. Linux has different software or has the software you need already integrated.
This project is exentdable as you wish. If you want to build also button for controlling the menu of OSMC itself, there will be a extension of this guide soon.
- Raspberry Pi 3 Model B with an Power Supply Unit (link to a Raspberry Pi Set)
- microSD Card (at least 8GB)
- Solderless Breadboard (I've used the Ever-Muse Electronic MB-102)
- five Push Buttons
- jumper wires
- NOOBS (New Out Of the Box Software) for an easy OSMC installation
- OSMC Distribution
- Keyboard, Mouse, Monitor for the Raspberry Pi
- Laptop/Computer (Windows)
- SD Formatter
- PuTTY
- GPIO T-adapter plate (It's an adapter for the GPIO pins, which you can plug onto the Breadboard . You see easier, where to plug in the buttons)
- GPIO rainbow Cable (Connection wire from GPIO pins to the T-adapter plate)
- DIY Starter Kit: This is a Complete Kit that contains hardware parts like the wires, push buttons, GPIO T-adapter plate or the GPIO rainbow Cable. There're many different Starter Kits available but here I have the link of the Starter Kit I use.
For a test we use also:
- one LED
- one 100 Ohm resistor
First of all you need to format your microSD, so that you can be sure that the microSD Card has no files on it.
I use SD Card Formatter for this. Just click on the link and download it. The program is nearly self-explanatory. Select the card you want to format and then press 'Format'.
After you've done this, we have to install NOOBS onto the microSD Card. Download the .zip here. It doesn't matter if you either install NOOBS or NOOBS Lite, because you need Internet Access to download and install OSMC anyway.
Once you've donwloaded the NOOBS zip file, you'll need to extract the files from the .zip. You can use a tool like 7-Zip.
Then copy the extracted files onto the SD Card, but every file each, not as one folder.
Before you boot your Raspberry Pi, make sure you've plugged the microSD Card, a Keyboard, Mouse and Monitor to it. If you've checked everything you can plug in the Power Supply Unit and the Raspberry Pi will start.
On the first boot, it will display a window in which you can connect the Raspberry Pi to your Wifi Network. You can also plug in a LAN-Cable, which makes the process easier. After that you can see serveral distributions (Operating Systems) which you can install. Select OSMC and let it install.
After installation it'll start the system and you are nearly ready to do your own things with OSMC. Select your Location and Timezone. Don't change your Hostname.
Now your ready to explore OSMC!
There're two ways to access the command line
- A local console login, using a connected keyboard
- Logging in over the network via SSH using client on a Windows system.
In order to work and test scripts easier we'll use the second way.
First we need to install an SSH Client on your Computer called PuTTY.
Linux and OS X users should have an SSH Client already.
Next we need the IP address of the Rapsberry Pi. You can find your device's IP address in the OSMC Settings:
Settings-> System Info -> Network
Run PuTTY and enter the IP address of your device and click 'Ok'. When prompted, enter osmc for both username and password. You are now in the command line of your OSMC distribution.
For more information and a Tutorial for Linux/OS X click here.
The first thing we have to do in the command line is to install the RPi.GPIO module. You need to install it in order to work with the GPIO pins.
Put this commands each into the command line:
$ sudo su
# apt-get update
# apt-get install python-pip python-dev gcc
# pip install rpi.gpioIt may showed some warnings but it will be sucessfully installed .
To get to known with GPIO pins, here is useful picture of the GPIO pins and their labels.

Use this picture if you want to connect hardware to the pins.
Now we're going to Test if the RPi.GPIO module was installed right.
We will build this circuit:
[pin 39] --- [jumper] --- [-LED+] --- [jumper] --- [R100ohm] --- [jumper] --- [pin 40]
Type into the command line (line after line):
$ sudo su
# python
>>> import RPi.GPIO as GPIO
>>> GPIO.setmode(GPIO.BOARD)
>>> GPIO.setup(40, GPIO.OUT)
>>> GPIO.output(40, 1)
>>> GPIO.output(40, 0)
>>> GPIO.cleanup()
>>> exit()When you type GPIO.output(40, 1), the LED will light up. GPIO.output(40, 0) shuts down the LED.
If that worked for you, you can go further in this guide.
If not then check your circuit and your code once again.
Finally we can build the actual circuit. It looks like this.
Make sure you connect every button to one GPIO pin that is free to use and to a 'Ground' pin.
If you look on the picture from the paragraph 'RPi.GPIO' you can see that there are some pins, that have a certain function.
You have to use the ones that are not marked red or yellow and on the other side of the button the 'Ground' pin.
So one not marked pin and one 'Ground' pin
The circuit isn't that complicated because you don't need a difficult circuit here.
After being done with building the circuit, we have to write the python scripts.
In this repository is every python script you need for your Control-Panel.
You can either donwload them on your Raspberry Pi and place them in '/home/osmc/' or you write them yourself by using the integrated text editor 'Nano'.
The first way is easy and is already explained. The second way is also not that hard to do.
In your command line type:
$ sudo su
# nano /home/osmc/example.pyPut for 'example.py' every name in that you want. Just make sure that it is ending with '.py'.
Now you've opened a python script in the file editor 'Nano'. You can write into this file one code which is in this repository. For every script that is in this repository (right now there are five) you need to make a new python script with:
$ sudo su
# nano /home/osmc/example.pyWhen you've wrote one code into one script you can save that code with CTRl+X and press enter if you don't want to change the name of the script. After this, you have to change the file permissions. Type:
# chmod +x /home/osmc/*.pyIf you want to test the script, type into the command line:
# python /home/osmc/example.pyIf the button does what it should do, then you go on with this guide.
To let the script run on startup, in order to use it right after you started OSMC, we need to change the rc.local file. It is a shell script that is run when the system is started up. Type this code to open the file:
$ sudo su
# nano /etc/rc.localYou'll see something like this:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0Then put into this script the following code before 'exit 0' and after '# By default this script does nothing':
sudo python /home/osmc/voldo.py &
sudo python /home/osmc/volup.py &
sudo python /home/osmc/Start.py &
sudo python /home/osmc/Prev.py &
sudo python /home/osmc/Next.py &If you used different python script names then insert yours into the code.
Don't forget the '&' after every command. You need this otherwise you could get an error, or your system will never start.
When you put the command into the file save the file and reboot your Raspberry Pi.
Every button should now work as intended by the scripts.
If not then check the 'rc.local' file again and your python scripts.
If you want to go one step further you can now try to write a script for controlling the OSMC menu with buttons.
In the abstract you only have to change the 'xbmc-send' command.
But that's something I didn't try yet.
- RPi.GPIO Pin picture: https://goo.gl/5VLTmJ
- xbmc-send commands: https://goo.gl/Ufafqx
- Running scripts on start up with rc.local: https://goo.gl/3vXNW6
- OSMC Wiki: https://osmc.tv/wiki/
