Introduction: Reuse Unwanted Infrared Remote Control to Shutdown and Reboot Raspberry Pi

About: Systems Administrator and Software Programmer.

Introduction

This remote control in the picture used to control a fan until the fan stopped working. I threw away the fan and saved the remote control unit. This is definitely my personal favourite instructable because it is is useful for lazy people like me. Too lazy to use click on menu, buttons, keyboards and mouse.

Scope

This instructable will show how to install and configure a LIRC client program, irexec:

  1. To shutdown the Raspberry Pi.
  2. To reboot the Raspberry Pi.

It will NOT cover how to add infrared interface to Raspberry Pi which is covered in my other instructable.

Target Readers

Anyone who has a Raspberry Pi with a infrared interface.

Step 1: Record and Map Infrared Codes to LIRC Events

Step 2: Make Raspberry Pi Respond to Remote Control Events

The remote control unit sends IR signals when its buttons are pressed. LIRC daemon captures the IR signals and translate it to LIRC events. However, it doesn't know what to do with the LIRC events. "irexec" is the program that will translate the LIRC events into actions. irexec is classified as a LIRC client

Create a configuration file that will tell irexec what to do when LIRC events occur.

$cd /etc/lirc

Enter the values as show in the screenshot.

$sudo vi lircrc

Step 3: Test

Open terminal emulator in Raspberry Pi

$sudo reboot

Point the remote control at the Raspberry Pi
Press the button that was mapped to "KEY_RESTART". The Raspberry Pi should reboot.

Press the button that was mapped to "KEY_POWER". The Raspberry Pi should power off.

If nothing happens, then it's time to debug.