TSOP 31238 as an IR reciever for Raspberry Pi

I wanted to try something new and easy upgrade for my OSMC media box. Here are the ingreedients:

  • Raspberry Pi with OSMC
  • TSOP31238 (0.5 € at ret.hu)
  • A remote (LG 6710CDAL01G)

Install TSOP31238

indexConnect pin 1 to GND (physical pin 14), pin 2 to a 3.3V (physical pin 17) and pin 3 to GPIO 18 (physical pin 12).

LOAD REQUIRED OVERLAY

GUI: Select My OSMC menu, select Pi Config and on the Hardware Support tab “Enable LIRC GPIO support”.

CLI (another method): Add the dtoverlay=lirc-rpi line to the /boot/config.txt file.

Reboot and check dmesg:

lirc_dev: IR Remote Control driver registered, major 245
lirc_rpi: module is from the staging directory, the quality is unknown, you have been warned.
lirc_rpi: auto-detected active low receiver on GPIO pin 18
lirc_rpi lirc_rpi: lirc_dev: driver lirc_rpi registered at minor = 0
lirc_rpi: driver registered!
input: lircd as /devices/virtual/input/input2

Configure REMOTE BUTTONS:

First you need to disable the lirc service to gain access to the new device:

sudo systemctl stop lircd_helper@lirc0

Then we configure the buttons (follow the instructions):

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

I named the following keys (on the unused number buttons):

  • KEY_OK – 5
  • KEY_HOME – 0
  • KEY_LEFT – 4
  • KEY_RIGHT – 6
  • KEY_UP – 2
  • KEY_DOWN – 8
  • KEY_PLAYPAUSE -3
  • KEY_BACK – 1

The following config was created:

begin remote

  name  /home/osmc/lg2-osmc.conf
  bits           16
  flags SPACE_ENC|CONST_LENGTH|REPEAT_HEADER
  eps            30
  aeps          100

  header       4530  4461
  one           581  1661
  zero          581   539
  ptrail        579
  repeat        578  1662
  pre_data_bits   16
  pre_data       0x3434
  gap          108020
  toggle_bit_mask 0x0

      begin codes
          KEY_PLAYPAUSE            0xC23D
          KEY_HOME                 0xD22D
          KEY_OK                   0xA25D
          KEY_UP                   0x42BD
          KEY_DOWN                 0x12ED
          KEY_LEFT                 0x22DD
          KEY_RIGHT                0x629D
          KEY_BACK                 0x827D
      end codes

end remote

I did not upload this config to the lirc database, as I haven’t configured every button.

Copy the config file to /etc/lirc/ and select the config file from the My OSMC >Remotes.

Reboot and enjoy.

Advertisements

Author: Gajdos Tamás

A "barefoot physicist" with some IT skills in system administration.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s