R&D Publishing‎ > ‎

Raspberry Pi LIRC

Universalfernbedienung (Raspberry Pi)

Created by Sebastian on Mon, 27/04/2015 - 22:32
Universalfernbedienung

In my last entry about universal remote the subject was treated with the Arduino. Integration into FHEM for home control is made more difficult, has to that communication between the devices takes place. Instead of a comprehensive protocol for data communication, the universal remote control is directly related to the Raspberry Pi implemented. In contrast to the Arduino, the GPIO ports are unfortunately operated with 3.3V instead of 5V.

Hardware

The hardware is similar to the Arduino directly connected to the GPIO ports. Here, the different availability of ports should be considered when the Raspberry Pi models. In this article, the terminal GPIO pin 22 is provided for the IR receiver and the GPIO pin 23 for the IR transmitter.

LIRC

Instead of a small library for IR detection and sending LIRC is used. "LIRC is the abbreviation for Linux Infrared Remote Control. This is a program for Linux that allows you can put commands from IR remotes in program instructions. What is needed is for only one infrared receiver. [...] To to decode the signals from remote controls correctly, you need a configuration file that is tailored to the respective remote control. you can either create this yourself, or download an appropriate file from the Internet. " (Source: Wikipedia )

Installation and setup on the Raspberry Pi there is an interesting article which serves for the following calls as a base. Installing LIRC done simply by apt-get.

$ sudo apt-get install lirc

To load the required modules manually and to test them there modprobe. In the lirc_rpi the correct assignment of the GPIO ports must be observed!

$ sudo modprobe lirc_dev
$ sudo modprobe lirc_rpi gpio_in_pin=22 gpio_out_pin=23

UPDATE: 27/04/2015: Immediately the module is no longer on / etc / modules GpsDrive but over /boot/config.txt

$ sudo vi /boot/config.txt
dtoverlay=lirc-rpi,gpio_out_pin=23,gpio_in_pin=22

The modules are loaded at startup, this must be entered in the modules file.

$ sudo vi /etc/modules
lirc_dev
lirc_rpi gpio_in_pin=22 gpio_out_pin=23

The lirc device can be determined by ls in the dev directory.

$ ls -l /dev/lir*
crw-rw---T 1 root video 248, 0 Jan  5 12:16 /dev/lirc0

In the config file of the LIRC device and the modules must be entered.

$ sudo vi /etc/lirc/hardware.conf
# -u --uinput            generate Linux input events
LIRCD_ARGS="--uinput"
DRIVER="default"
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"

Restarting the daemon.

$ sudo /etc/init.d/lirc restart

test receiver

The receiver can be tested to determine its basic functionality by using the LIRC daemon gestommt and by mode2 the RAW output is viewed by the device. Pressing any key on a IR remote control should turn space and pule entries appear.

$ sudo /etc/init.d/lirc stop
$ mode2 -d /dev/lirc0
space 1622
pulse 667
space 1573
pulse 675

testing stations

The initial lircd.conf is empty. It can be used either existing configuration files, unless you record your own which are for the remote control, or.

$ cat /etc/lirc/lircd.conf

Existing configuration file

In the SourceForce remote project many remotes have already been recorded. Also provides with LIRC own files.

$ ls /usr/share/lirc/remotes/

When YAMAHA RAX9 remote control, there is already a file in the project.

$ mkdir lirc
$ cd lirc
$ wget http://lirc.sourceforge.net/remotes/yamaha/RAX9
$ sudo cp RAX9 /etc/lirc/lircd.conf

The program irw the inputs of the remote control can be read.

$ irw 
000000005ea158a7 03 vol+ rax9
000000005ea1e817 00 aux rax9

If there is no output appear the daemon testweise be started in the foreground. Errors or warnings are displayed Possibly here.

$ sudo /etc/init.d/lirc stop
$ sudo lircd --nodaemon -H devinput

You can send faxes using irsend.

$ irsend SEND_ONCE rax9 aux

Create your own configuration file

The daemon is stopped and a separate file for each remote is irrecord with the program recorded.

$ sudo /etc/init.d/lirc stop

For SAMSUNG - AA59-00743A remote control a possible call would be as follows.

$ sudo irrecord -H default -d /dev/lirc0 AA59-00743A

The program guides the user through the process of recording. The list of key codes helps correct assignment. After picking up the generated file is copied as new /etc/lirc/lircd.conf and restart the daemon. Agent irw as described above can be found in the pressed keys.

$ sudo cp AA59-00743A.conf /etc/lirc/lircd.conf
$ sudo /etc/init.d/lirc restart
$ irw
00000000e0e040bf 00 KEY_POWER Samsung_AA59-00743A
$ irsend SEND_ONCE Samsung_AA59-00743A KEY_POWER

The same is for all other remote control performed (here, the LG - AKB73615701).

sudo irrecord -H default -d /dev/lirc0 AKB73615701

At the end of all the configuration files into one file and used as new lircd.conf.

$ cat *.conf > lircd.conf
$ sudo cp lircd.conf /etc/lirc/lircd.conf

or

cat AKB73615701.conf AA59-00743A.conf RAX9 > lircd.conf
sudo cp lircd.conf /etc/lirc/lircd.conf

FHEM Einbindung

With the module Remotcontrol a floorplan can be created. On the Floor Plan, all keys are stored. The Samsung remote control may be defined as follows.

define RC_TV remotecontrol
attr RC_TV rc_iconpath icons/remotecontrol
attr RC_TV rc_iconprefix black_btn_
attr RC_TV room 1.0_Wohnzimmer
attr RC_TV row00 KEY_POWER:POWEROFF,:blank,KEY_SELECT:SOURCE
attr RC_TV row02 :blank,:blank,:blank
attr RC_TV row03 KEY_1:1,KEY_2:2,KEY_3:3
attr RC_TV row04 KEY_4:4,KEY_5:5,KEY_6:6
attr RC_TV row05 KEY_7:7,KEY_8:8,KEY_9:9
attr RC_TV row06 :blank,KEY_0:0,KEY_REWIND:PRECH
attr RC_TV row07 :blank,:blank,:blank
attr RC_TV row08 KEY_VOLUMEUP:UP,KEY_MUTE:MUTE,KEY_CHANNELUP:CHUP
attr RC_TV row09 KEY_VOLUMEDOWN:DOWN,:blank,KEY_CHANNELDOWN:CHDOWN
attr RC_TV row10 KEY_MENU:MENU,:blank,KEY_PROGRAM:GUIDE
attr RC_TV row11 :blank,:blank,:blank
attr RC_TV row12 :blank,KEY_UP:UP,KEY_INFO:INFO
attr RC_TV row13 KEY_LEFT:LEFT,KEY_ENTER:ENTER,KEY_RIGHT:RIGHT
attr RC_TV row14 :blank,KEY_DOWN:DOWN,KEY_EXIT:EXIT
define NRC_TV notify RC_TV {system("irsend SEND_ONCE Samsung_AA59-00743A $EVENT")}

The values ​​and rc_iconpath rc_iconprefix define the path for the images. Agent rowXX the lines defined by the buttons. Each button is stored internally by EVENT: IMAGE. The notify treats the click of the button and sends the EVENT at irsend.

Examples of the generated files


# Please make this file available to others
# by sending it to 
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sun Jan  5 13:37:55 2014
#
# contributed by
#
# brand:                       Samsung_AA59-00743A
# model no. of remote control:
# devices being controlled by this remote:
#

begin remote

  name  Samsung_AA59-00743A
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       4532  4449
  one           595  1635
  zero          595   520
  ptrail        597
  pre_data_bits   16
  pre_data       0xE0E0
  gap          107492
  toggle_bit_mask 0x0

      begin codes
          KEY_NEXT                 0x12ED
          KEY_POWER                0x40BF
          KEY_1                    0x20DF
          KEY_2                    0xA05F
          KEY_3                    0x609F
          KEY_4                    0x10EF
          KEY_5                    0x906F
          KEY_6                    0x50AF
          KEY_7                    0x30CF
          KEY_8                    0xB04F
          KEY_9                    0x708F
          KEY_0                    0x8877
          KEY_SELECT               0x807F
          KEY_VOLUMEDOWN           0xD02F
          KEY_VOLUMEUP             0xE01F
          KEY_CHANNELDOWN          0x08F7
          KEY_CHANNELUP            0x48B7
          KEY_MENU                 0x58A7
          KEY_PROGRAM              0xF20D
          KEY_INFO                 0xF807
          KEY_ENTER                0x16E9
          KEY_EXIT                 0xB44B
          KEY_REWIND               0x1AE5
          KEY_MUTE                 0xF00F
          KEY_LEFT                 0xA659
          KEY_RIGHT                0x46B9
          KEY_UP                   0x06F9
          KEY_DOWN                 0x8679
      end codes

end remote
@bartelmus.de>

PROVISIONAL LG file! (Keys are missing!)


# Please make this file available to others
# by sending it to 
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sun Jan  5 14:24:26 2014
#
# contributed by
# Sebastian Pech - www.spech.de
# brand:                      LG
# model no. of remote control: AKB73615701
# devices being controlled by this remote:
#

begin remote

  name LG_AKB73615701
  bits           16
  flags SPACE_ENC|CONST_LENGTH|REPEAT_HEADER
  eps            30
  aeps          100

  header       4525  4429
  one           605  1625
  zero          605   509
  ptrail        604
  repeat        600   511
  pre_data_bits   16
  pre_data       0xB4B4
  gap          107515
  toggle_bit_mask 0x0

      begin codes
          KEY_POWER                0x0CF3
          KEY_1                    0xDC23
          KEY_FASTFORWARD          0x2CD3
          KEY_FORWARD              0xCC33
          KEY_REWIND               0xAC53
          KEY_PREVIOUS             0x4CB3
          KEY_NEXT                 0xCC33
          KEY_TITLE                0x52AD
          KEY_MENU                 0x5CA3
          KEY_HOME                 0xE619
          KEY_UP                   0xE21D
          KEY_DOWN                 0x12ED
          KEY_LEFT                 0x9A65
          KEY_RIGHT                0x5AA5
          KEY_ENTER                0x1AE5
          KEY_BACK                 0xA25D
          KEY_SUBTITLE             0x0AF5
          KEY_TITLE                0xD22D
      end codes

end remote
@bartelmus.de>

Problems

Are there these are deleted in the line 1 must lircd.conf the entry #UNCONFIGURED. Otherwise, the following message appears at startup.

$ sudo /etc/init.d/lirc restart
[ ok ] Reconfigure LIRC or manually replace /etc/lirc/lircd.conf to enable..
http://www.spech.de/sites/default/files/styles/juicebox_square_thumb/public/blogpage_gallery/foto_2_0.jpg?itok=P1_C4zVl
http://www.spech.de/sites/default/files/blogpage_gallery/foto_2_0.jpg

Comments

Elqubanitos (not verified)

Fr, 02.09.2016 - 14:47

Permanent link

Help ....

:( I'm nearing despair 
've been looking all over the wets but find nothing to my problem. 
Have a raspberry pi 2 and everything funzt actually up on irsend.

root@ir:~# irsend SEND_ONCE tvpanasonic KEY_1
irsend: command failed: SEND_ONCE tvpanasonic KEY_1
irsend: unknown remote: "tvpanasonic"

have constantly the message. Hopefully someone has an idea?

Sebastian

Fr, 23.09.2016 - 13:11

Permanent link

In reply to help ....by Elqubanitos (not verified)

Hi, do you have a ...

Hi, do you have an entry in the config file "begin remote" and "name tvpanasonic"?

 

Some links are Amazon affiliate links and support the development of the website. Thanks for your shopping on one of the links! I am also a small donation by PayPal.Me/SPech .

Comments