element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi Projects
  • Products
  • Raspberry Pi
  • Raspberry Pi Projects
  • More
  • Cancel
Raspberry Pi Projects
Blog Adding IR remote control to the Kodi media center running on a Raspberry Pi
  • Blog
  • Documents
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Matt
  • Date Created: 15 Sep 2017 12:14 PM Date Created
  • Views 5604 views
  • Likes 4 likes
  • Comments 0 comments
  • remote control
  • rpibeginner
  • tsop4838
  • kodi
  • raspberry pi
  • ir
  • raspberry_pi_projects
  • osmc
Related
Recommended

Adding IR remote control to the Kodi media center running on a Raspberry Pi

Matt
Matt
15 Sep 2017

You may have seen my blog post about creating a small portable media center that I can easily take on holiday to hook up to the hotel TV. If not, you can find it here;

 

Raspberry Pi powered media center to take on holiday

 

To reduce the amount space it took up, I used a cheap USB keypad which could be used to control the media center. It worked really well & having something hard-wired meant I didn't have to worry about a Bluetooth-paired device needing re-pairing.

 

However, what I then realised was it would be good to be able to use a spare remote control instead. I was using the OpenElec distribution and looked through their documentation for how to do this, but only found references to version 3 of the software (it's on version 7) and how to get LIRC working with it. There were plenty of blog posts on hooking up IR support, but a lot of them were written 2-3 years ago, and the software has moved on somewhat.

 

Hardware Setup

 

What I did first was buy a suitable IR receiver. I chose the Vishay TSOP4838TSOP4838 (which costs less than £1) because of the voltage range (2.5-5.5v) and receiver frequency (38KHz). If you look at the datasheet for the product, you'll see which pins should get wired up to the Pi;

 

image

 

Simply wire pin 1 to GPIO 18, pin 2 to GND, and pin 3 to a 3.3v power pin, e.g.

 

image

 

By using some short F-F jumper wires and a small cut in the side of the case, I was able to position the reciever neatly(ish) on the side.. it's still easily removable, but you could integrate it into the case a bit more seamlessly than this image

 

image

 

image

 

image

 

Software Setup

 

Before this project I was using OpenElec, but had limited success getting the IR support working properly. I switched to OSMC which I'd read had better IR support through the main UI. I think I was actually on the right track with OpenElec, but I realised later that the old vintage Xbox remote I was trying to use wasn't 100% working.

 

If you're going to use a remote control that's officially recognised, then you can jump this part about learning IR remote control codes.

 

Learning IR remote commands

 

The remote I found in the loft was an old DVD player remote which (unsurprisingly) wasn't in the list of pre-recognised remotes in the OSMC installation. I needed to get the Pi to learn the IR pulses being sent out by the remote and map them to the Kodi functions.

 

1. First off, you need to telnet to the Pi. Username: osmc, Password: osmc.

 

2. Next you need to stop the LIRC service which is being locked/used by Kodi

 

sudo systemctl stop lircd_helper@lirc0

 

3. Now you can run the IR learn mode.. this will record what it finds to the config file you specify;

 

irrecord -d /dev/lirc0 /home/osmc/lircd.conf

 

4. Follow the on-screen instructions which will recognise your remote.

 

One observation I had was that this only worked properly if I stopped after the first prompt to press lots of keys on the remote.. if I completed the second stage, the key mapping didn't work, e.g.

image

 

If I ignored the second phase & let it abort, the learn process worked image

 

image

 

When it's working, you'll be able to enter the Kodi function (like KEY_UP, KEY_DOWN, etc)  & map it to a key press on your remote;

image

 

Once you've mapped all the functions you want, we then need to move back to OSMC and tell it to use that config file we've just written.

 

OSMC Settings

 

In OSMC you need to do the following;

 

1. Disable the CEC service (via System Settings > Input > Peripherals > CEC Adapter), which seems to be needed for LIRC to work.

2. Now go into OSMC settings and pick the Raspberry Pi icon

 

image

 

2. Go into Hardware Support and enabled LIRC GPIO Support. You shouldn't need to change anything if you connected the sensor to GPIO 18.

 

image

 

3. Now go back and select the Remote Control option;

 

image

 

4. Ignore the list of pre-installed remotes and select Browse;

 

image

 

5. Navigate to the folder where LIRC wrote your config file;

 

image

 

6. Confirm the change & reboot the box;

 

image

 

That should be it.. your remote should be able to control everything in Kodi.

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube