{"id":249,"date":"2014-05-11T20:39:19","date_gmt":"2014-05-11T19:39:19","guid":{"rendered":"http:\/\/www.anginf.de\/?p=249"},"modified":"2016-08-31T10:27:19","modified_gmt":"2016-08-31T08:27:19","slug":"raspberry-pi-on-lg-42lh9000-with-openelec-and-ir-remote","status":"publish","type":"post","link":"https:\/\/www.anginf.de\/?p=249","title":{"rendered":"Raspberry Pi on LG 42LH9000 with OpenELEC and IR Remote"},"content":{"rendered":"<hr \/>\n<p><strong>UPDATE:<\/strong> Newest kernels require you to add the GPIO-Information directly into the config.txt, otherwise the LIRC won&#8217;t be available:<\/p>\n<p>Append this to your <code>\/boot\/config.txt<\/code> (if you attach the IR receiver to GPIO 23 as stated in the article below):<\/p>\n<pre lang=\"bash\">dtoverlay=lirc-rpi,gpio_in_pin=23\r\n<\/pre>\n<hr \/>\n<p>I attached a Raspberry PI (Model B) via HDMI to my <a title=\"LG-42LH9000 @ LG\" href=\"http:\/\/www.lg.com\/de\/tv\/lg-42LH9000-led-lcd-tv\" target=\"_blank\">LG 42LH9000<\/a>, a 42&#8243; LED-TV from 2009. With the newest version of <a title=\"OpenELEC Homepage\" href=\"http:\/\/openelec.tv\/\" target=\"_blank\">OpenELEC 4.0.0<\/a>, I was suprised to find out that the most commands via CEC work out nicely. The only trouble I had was, that the &#8222;Back&#8220; and &#8222;Exit&#8220;-Buttons didn&#8217;t work at all. Instead, I had to press &#8222;STOP&#8220; and &#8222;OK&#8220; directly after each other in a short time for &#8222;Back&#8220; and &#8222;STOP&#8220; and &#8222;PAUSE&#8220; for an &#8222;Exit&#8220;.<\/p>\n<p>As I was using an IR remote control anyways, I thought the raspberry could receive the data for the two missing buttons directly. At first, I needed an IR receiver diode. That was easy, as I still had an old, broken mini-helicopter which was steered using IR. As the helicopter itself was useless, I desoldered the IR receiver. I couldn&#8217;t make out a model number, so I simply guessed.<\/p>\n<p>Facing the side with the receiver (that&#8217;s the side with the little bump), you can see three legs coming out of it. The left one I used for &#8222;DATA&#8220;, the middle one for &#8222;GND&#8220; and the right one for &#8222;Vs&#8220;. As the helicopter was working with a lithium battery, I simply guessed that the receiver will work out nicely with only 3.3V.<\/p>\n<p>Next step was wiring the receiver to the Raspberry PI. I needed +3.3V, GND and a useful GPIO-pin. Searching the web, I found this great view of the GPIOs. I&#8217;m sorry that I can&#8217;t give any credit to the one who created this graphic, as there are no copyright notices anywhere to find.<\/p>\n<figure id=\"attachment_251\" aria-describedby=\"caption-attachment-251\" style=\"width: 300px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.anginf.de\/wp-content\/uploads\/raspberry-pi-rev2-gpio-pinout.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-251\" src=\"https:\/\/www.anginf.de\/wp-content\/uploads\/raspberry-pi-rev2-gpio-pinout-300x209.jpg\" alt=\"Raspberry PI Rev2 GPIO pinout\" width=\"300\" height=\"209\" srcset=\"https:\/\/www.anginf.de\/wp-content\/uploads\/raspberry-pi-rev2-gpio-pinout-300x209.jpg 300w, https:\/\/www.anginf.de\/wp-content\/uploads\/raspberry-pi-rev2-gpio-pinout-1024x714.jpg 1024w, https:\/\/www.anginf.de\/wp-content\/uploads\/raspberry-pi-rev2-gpio-pinout.jpg 1050w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-251\" class=\"wp-caption-text\">Raspberry PI Rev2 GPIO pinout<\/figcaption><\/figure>\n<p>I attached the left (&#8222;DATA&#8220;)-leg to GPIO 23, the middle leg to GND and the right leg (&#8222;Vs&#8220;) to +3.3V.<\/p>\n<p>After logging into my Raspberry PI, which was already running OpenELEC, I tried these commands to test if the IR receiver was working:<\/p>\n<pre lang=\"bash\">modprobe lirc_rpi gpio_in_pin=23 debug=1\r\ndmesg\r\n<\/pre>\n<p>The <code>dmesg<\/code> should return something like this:<\/p>\n<pre>[118254.914704] lirc_dev: IR Remote Control driver registered, major 248\r\n[118254.915686] lirc_rpi: module is from the staging directory, the quality is unknown, you have been warned.\r\n[118254.939532] lirc_rpi: is_right_chip bcm2708_gpio 0\r\n[118254.939904] lirc_rpi: to_irq 193\r\n[118255.831302] lirc_rpi: auto-detected active low receiver on GPIO pin 23\r\n[118255.831921] lirc_rpi lirc_rpi.0: lirc_dev: driver lirc_rpi registered at minor = 0\r\n[118255.831946] lirc_rpi: driver registered!\r\n<\/pre>\n<p>Now we want to make sure that the receiver is actually working. Grap your remote control, run this command and see if anything happens on the console.<\/p>\n<pre lang=\"bash\">mode2 -d \/dev\/lirc0\r\n<\/pre>\n<p>This is my example output when I hit the &#8222;BACK&#8220;-Button on my remote control:<\/p>\n<pre>space 2189447\r\npulse 9022\r\nspace 4473\r\npulse 571\r\nspace 611\r\npulse 520\r\nspace 567\r\npulse 584\r\nspace 1658\r\npulse 588\r\nspace 541\r\npulse 588\r\nspace 552\r\npulse 590\r\nspace 542\r\npulse 587\r\nspace 541\r\npulse 568\r\nspace 571\r\npulse 585\r\nspace 1659\r\npulse 586\r\nspace 1696\r\npulse 544\r\nspace 547\r\npulse 562\r\n<\/pre>\n<p>The IR receiver actually works and we just saw the RAW input from the sensor!<\/p>\n<p>To make sure that the next time the Raspberry PI is started, that the module is loaded correctly, type in this command:<\/p>\n<pre lang=\"bash\">echo \"options lirc_rpi gpio_in_pin=23\" &gt;\/storage\/.config\/modprobe.d\/lirc_rpi.conf\r\n<\/pre>\n<p>Make sure that no LIRCD is running:<\/p>\n<pre lang=\"bash\">killall lircd\r\n<\/pre>\n<p>And start recording the input from the two buttons:<\/p>\n<pre lang=\"bash\">mkdir -p ~\/work\/lirc\r\ncd ~\/work\/lirc\r\nirrecord -d \/dev\/lirc0 inputlg\r\n<\/pre>\n<p>The last command guides you through a wizard, the two buttons are called <code>BTN_BACK<\/code> and <code>KEY_EXIT<\/code>. I added the RED button as well and mapped it to <code>KEY_C<\/code>, as this is the context menu for the KODI.<\/p>\n<p>As a result, you should have a file <code>inputlg<\/code> with these contents:<\/p>\n<pre lang=\"ini\"># Please make this file available to others\r\n# by sending it to &lt;lirc@bartelmus.de&gt;\r\n#\r\n# this config file was automatically generated\r\n# using lirc-0.9.1-git(default) on Sun May 11 22:47:19 2014\r\n#\r\n# contributed by\r\n#\r\n# brand:                       inputlg.conf\r\n# model no. of remote control:\r\n# devices being controlled by this remote:\r\n#\r\n\r\nbegin remote\r\n\r\n  name  inputlg.conf\r\n  bits           16\r\n  flags SPACE_ENC|CONST_LENGTH\r\n  eps            30\r\n  aeps          100\r\n\r\n  header       9006  4492\r\n  one           565  1677\r\n  zero          565   566\r\n  ptrail        562\r\n  repeat       9008  2246\r\n  pre_data_bits   16\r\n  pre_data       0x20DF\r\n  gap          108236\r\n  toggle_bit_mask 0x0\r\n\r\n      begin codes\r\n          KEY_EXIT                 0x14EB\r\n          KEY_MENU                 0xDA25\r\n          KEY_C                    0x4EB1\r\n      end codes\r\n\r\nend remote\r\n<\/pre>\n<p>As you can see I really only added the two buttons that I still needed. If you want to add any more buttons, you must know the correct names for them. These can be retrieved with a simple command. As there are MANY possible buttons available, I limit the output to those which might be useful for me. The following command for example shows me the &#8222;EXIT&#8220;-Button:<\/p>\n<pre lang=\"bash\">irrecord --list-namespace | grep -i exit\r\n<\/pre>\n<p>I assigend my &#8222;BACK&#8220;-Button from the remote to &#8222;KEY_EXIT&#8220;, as this works like a &#8222;back-button&#8220; within KODI. The &#8222;EXIT&#8220;-Button from my remote is used as a &#8222;MENU&#8220; key.<\/p>\n<p>If you want to know which buttons are used by KODI (and in what manner), the answers lie inside the file <code>\/usr\/share\/kodi\/system\/Lircmap.xml<\/code> with the section <code><\/code><\/p>\n<p>Now copy the file to the correct location:<\/p>\n<pre lang=\"bash\">cp inputlg \/storage\/.config\/lircd.conf\r\n<\/pre>\n<p>And reboot:<\/p>\n<pre lang=\"bash\">sync\r\nreboot\r\n<\/pre>\n<p>If you want to add other keys, which are normally not part of the remote control, here are the steps to work it our correctly:<\/p>\n<p>Make sure that you have the Lircmap.xml from the system in your storage:<\/p>\n<pre lang=\"bash\">cp \/usr\/share\/kodi\/system\/Lircmap.xml \/storage\/.kodi\/userdata\/Lircmap.xml\r\n<\/pre>\n<p>And add in the last section which starts with <code>&lt;remote device=\"devinput\"&gt;<\/code> the following information:<\/p>\n<pre lang=\"xml\">KEY_C\r\n<\/pre>\n<p>Here are the links that helped me set this up:<br \/>\n<a title=\"OpenELEC Guide\" href=\"http:\/\/wiki.openelec.tv\/index.php?title=Guide_To_lirc_rpi_GPIO_Receiver\">http:\/\/wiki.openelec.tv\/index.php?title=Guide_To_lirc_rpi_GPIO_Receiver<\/a><br \/>\n<a title=\"OpenELEC Guide Test and Remap\" href=\"http:\/\/wiki.openelec.tv\/index.php?title=Guide_To_Test_a_Remote_and_Remap_Keys\" target=\"_blank\">http:\/\/wiki.openelec.tv\/index.php?title=Guide_To_Test_a_Remote_and_Remap_Keys<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>UPDATE: Newest kernels require you to add the GPIO-Information directly into the config.txt, otherwise the LIRC won&#8217;t be available: Append this to your \/boot\/config.txt (if you attach the IR receiver to GPIO 23 as stated in the article below): dtoverlay=lirc-rpi,gpio_in_pin=23 I attached a Raspberry PI (Model B) via HDMI to my LG 42LH9000, a 42&#8243; &hellip; <a href=\"https:\/\/www.anginf.de\/?p=249\" class=\"more-link\"><span class=\"screen-reader-text\">Raspberry Pi on LG 42LH9000 with OpenELEC and IR Remote<\/span> weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,2],"tags":[],"class_list":["post-249","post","type-post","status-publish","format-standard","hentry","category-allgemein","category-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/posts\/249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anginf.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=249"}],"version-history":[{"count":33,"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/posts\/249\/revisions"}],"predecessor-version":[{"id":457,"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/posts\/249\/revisions\/457"}],"wp:attachment":[{"href":"https:\/\/www.anginf.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anginf.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anginf.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}