Preamble
Here’s what you need to do in order to get LIRC working properly on Raspbian:
- Make sure you are running the version of Raspbian which has the LIRC modules included
- Install lirc from apt-get
- Add a couple of entries into the /etc/modules file
- Use dmesg to ensure the Lirc settings have loaded properly
- Run a system command to ensure the the device is reading the signals from the remote control
- Run an lirc program to record the IR commands from the remote control
- Test the IR commands are being properly interpreted by the final setup.
Here’s the steps in detail:
Upgrading Raspbian
type `apt-get upgrade`
Install lirc from apt-get
type `apt-get install lirc`
Here’s the output from that:
Reading package lists… Done Building dependency tree Reading state information… Done Suggested packages: lirc-x setserial ir-keytable The following NEW packages will be installed: lirc 0 upgraded, 1 newly installed, 0 to remove and 354 not upgraded. Need to get 562 kB of archives. After this operation, 1,784 kB of additional disk space will be used. Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main lirc armhf 0.9.0~pre1-1 Fetched 562 kB in 2min 7s (4,404 B/s) Selecting previously unselected package lirc. (Reading database … 103145 files and directories currently installed.) Unpacking lirc (from …/lirc_0.9.0~pre1-1_armhf.deb) … Processing triggers for man-db … Setting up lirc (0.9.0~pre1-1) … No valid /etc/lirc/lircd.conf has been found.. Remote control support has been disabled.. Reconfigure LIRC or manually replace /etc/lirc/lircd.conf to enable..
Modify the /etc/modules file
I added the following lines to /etc/modules
lirc_dev lirc_rpi gpio_in_pin=18 gpio_out_pin=25
Also changed the file /etc/lirc/hardware.conf
************************************************########
LIRCD_ARGS=”–uinput”
LOAD_MODULES=true
DRIVER=”default”
DEVICE=”/dev/lirc0″ MODULES=”lirc_rpi”
LIRCD_CONF=”” LIRCMD_CONF=”” ########################################################
Now restart lircd so it picks up these changes:
sudo /etc/init.d/lirc stop sudo /etc/init.d/lirc start
## Check dmesg
It should look something like this:
lirc_dev: IR Remote Control driver registered, major 248 lirc_rpi: module is from the staging directory, the quality is unknown, you have been warned. lirc_rpi lirc_rpi.0: lirc_dev: driver lirc_rpi registered at minor = 0 lirc_rpi: driver registered! lirc_rpi: auto-detected active low receiver on GPIO pin 18 input: lircd as /devices/virtual/input/input0
Initial test
Type the following:
sudo /etc/init.d/lirc stop mode2 -d /dev/lirc0
Point a remote control at your IR receiver and press some buttons. You should see something like this:
space 16300 pulse 95 space 28794 pulse 80 space 19395 pulse 83 space 402351 pulse 135 space 7085 pulse 85 space 2903
Recording IR commands
Be sure to run `irrecord –list-namespace` to see the valid names before you begin.
Here were the commands that I ran to generate a remote configuration file:
sudo /etc/init.d/lirc stop
irrecord -d /dev/lirc0 ~/lircd.conf
sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf
sudo cp ~/lircd.conf /etc/lirc/lircd.conf
sudo /etc/init.d/lirc start
Testing the final setup.
type `irw` to detect the commands
example output:
0000000000000002 00 KEY_DOWN /home/james/lircd.conf 0000000000000002 01 KEY_DOWN /home/james/lircd.conf 0000000000000002 02 KEY_DOWN /home/james/lircd.conf 0000000000000002 03 KEY_DOWN /home/james/lircd.conf 0000000000000001 00 KEY_CHANNELUP /home/james/lircd.conf 0000000000000001 01 KEY_CHANNELUP /home/james/lircd.conf 0000000000000001 02 KEY_CHANNELUP /home/james/lircd.conf 0000000000000001 03 KEY_CHANNELUP /home/james/lircd.conf 0000000000000003 00 KEY_POWER /home/james/lircd.conf 0000000000000003 01 KEY_POWER /home/james/lircd.conf 0000000000000003 02 KEY_POWER /home/james/lircd.conf
Playing back
1 2 3 4 |
irsend LIST REMOTE_NAME "" irsend SEND_ONCE REMOTE_NAME CONTROL_1 |
Resources
- [ ] [Using an IR Remote with a Raspberry Pi Media Center](http://learn.adafruit.com/using-an-ir-remote-with-a-raspberry-pi-media-center/using-other-remotes)
- [ ] [Setting up LIRC on the RaspberryPi](http://alexba.in/blog/2013/01/06/setting-up-lirc-on-the-raspberrypi/)
- [ ] [Using the LIRC client for Ruby](http://www.jamesrobertson.eu/snippets/2013/may/19/using-the-lirc-client-for-ruby.html)
lirc raspbian rpi
Setting up a web-application
Install Node Js
1 2 3 4 5 6 |
wget http://node-arm.herokuapp.com/node_latest_armhf.deb sudo dpkg -i node_latest_armhf.deb node -v #v4.12 |
Setting up lirc_web
1 2 3 4 5 6 |
sudo git clone https://github.com/alexbain/lirc_web.git cd ./lirc_web sudo npm install node app.js |
<a href="http://192.168.1.xx%3A3000%7B/php">http://192.168.1.xx:3000{/php</a>]} </p></div></div></div><div id="outline-container-org076a07f" class="outline-2"><h2 id="org076a07f">Running Lirc_web With Nginx and Upstart</h2><div class="outline-text-2" id="text-org076a07f"><p> `To accomplish this will take three steps: </p><ol class="org-ol"><li>Configure the hostname for the RaspberryPi</li><li>Install and configure Upstart</li><li>Install and configure NGINX</li></ol></div><div id="outline-container-org9f1f308" class="outline-3"><h3 id="org9f1f308">Configure the hostname for the RaspberryPi and Auto Start with System</h3><div class="outline-text-3" id="text-org9f1f308">[crayon-673f06d2aa76c677103222 language="sh" title="" ]sudo apt-get install upstart# You will be asked to type 'Yes, do as I say!'# You may see an error about initctl being unable to connect, which will be fixed after a reboot# Reboot the RaspberryPisudo shutdown -r now
{php}/etc/init/open-source-universal-remote.conf[/crayon]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# /etc/init/open-source-universal-remote.conf description "universalremote.local" start on runlevel [2345] stop on runlevel [016] # Restart when job dies respawn # Give up restart after 5 respawns in 60 seconds respawn limit 5 60 script echo $$ > /var/run/open-source-universal-remote.pid exec /usr/local/bin/node /home/pi/lirc_web/app.js 2>&1 >> /var/log/open-source-universal-remote.upstart.log end script pre-start script # Date format same as (new Date()).toISOString() for consistency echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/open-source-universal-remote.upstart.log end script pre-stop script rm /var/run/open-source-universal-remote.pid echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/open-source-universal-remote.upstart.log end script |
After creating the Upstart script, you should be able to start the lirc_web project by running:
1 2 3 |
sudo initctl start open-source-universal-remote |
Install and Configure Upstart and NGINX
Upstart configuration
1 2 3 |
sudo apt-get install upstart |
and create the config file in /etc/init/open-source-universal-remote.conf:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# /etc/init/open-source-universal-remote.conf description "universalremote.local" start on runlevel [2345] stop on runlevel [016] # Restart when job dies respawn # Give up restart after 5 respawns in 60 seconds respawn limit 5 60 script echo $$ > /var/run/open-source-universal-remote.pid exec /usr/local/bin/node /home/pi/lirc_web/app.js 2>&1 >> /var/log/open-source-universal-remote.upstart.log end script pre-start script # Date format same as (new Date()).toISOString() for consistency echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/open-source-universal-remote.upstart.log end script pre-stop script rm /var/run/open-source-universal-remote.pid echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/open-source-universal-remote.upstart.log end script |
After creating the Upstart script, you should be able to start the lirc_web project by running:
1 2 3 |
sudo initctl start open-source-universal-remote |
You can verify everything works by opening http://universalremote.local:3000
NGINX
1 2 3 4 5 |
sudo apt-get install nginx update-rc.d nginx defaults sudo service nginx start |
You should see a “Welcome to nginx!” web page when you access {php}http://universalremote.local{/php} in your web browser.
1 2 3 |
sudo nano /etc/nginx/conf.d/open-source-universal-remote.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
server { listen 80; server_name universalremote.local; # Change this to the location you installed lirc_web root /home/pi/lirc_web; index index.html index.htm; access_log /var/log/open-source-universal-remote.nginx.log; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:3000/; proxy_redirect off; } } |
Notes
problems: http://archlinuxarm.org/forum/viewtopic.php?f=57&t=8851 locate downgrade version: http://tech.enekochan.com/en/2014/03/08/upgradedowngrade-to-a-specific-firmware-kernel-version-with-rpi-update-in-raspbian/
installation in Arch linux: http://bofhsolutions.blogspot.com/2014/12/raspberry-pi-lirc-arch-linux.html
tan@archipi ~$ sudo cat /sys/kernel/debug/gpio GPIOs 0-53, platform/3f200000.gpio, pinctrl-bcm2835: gpio-35 (? ) in hi gpio-47 (? ) out lo
Another version of lirc-web: https://github.com/jdavisonc/rasparmony
FEB
About the Author:
Beyond 8 hours - Computer, Sports, Family...