The idea here is to control a chromium webpage via a simple remote control (the usecase I am using it for is full-screen TV-like prototypes). More information is in this blog post: https://planb.nicecupoftea.org/2016/12/23/lirc-on-a-raspberry-pi-for-a-silver-apple-remote/
- Gather hardware
- Image an SD card for the Pi
- Install pre-requisites and this repo
- Make it all run on boot
You will need
- a tiny IR reciever (e.g. http://uk.farnell.com/vishay/tsop4838/ir-receiver-38khz/dp/4913190)
- 3 x female-female jumper wires.
- Raspberry pi 3 (other versions can't manage the chromium + css)
- 2.5 AMP power supply (you might get away with less but this is the offical Pi3 supply requirement)
- 8GB Micro SD card
With the pi switched off, attach the IR receiver as shown:
i.e. in this gpio diagram: https://www.raspberrypi.org/documentation/usage/gpio-plus-and-raspi2/
- GPIO 18 ir (1)
- ground to centre leg (2)
- 3.3V to ir power (3)
Download a full Jessie, not lite or NOOBS. I'm asumming 2016-09-23 release and a Pi3. This is on a Mac.
(N is a number, usually 2 for me)
diskutil list
diskutil unmountDisk /dev/diskN
sudo dd bs=1m if=~/Downloads/2016-09-23-raspbian-jessie.img of=/dev/rdiskN
While the SD card is still in your main machine, in config enable lirc module
sudo pico /Volumes/boot/config.txt
Uncomment this to enable the lirc-rpi module
dtoverlay=lirc-rpi
Depending on your version of Jessie, you may need to enable ssh (again before ejecting)
touch /Volumes/boot/ssh
Login to the pi
sudo apt-get install lirc #needed ??
sudo apt-get install xdotool
get this repo
git clone [email protected]:bbc/lirc-example.git
if you want to record your own remote
irrecord -d /dev/lirc0 my-remote.lircd
or use the one provided (for an appleTV 2nd gen - silver remote)
sudo cp lirc-example/lirc/my-remote.lircd /etc/lirc/lircd.conf
cp lirc-example/lirc/lircrc > /home/pi/.lircrc
cp -r lirc-example/lirc/keycommands /home/pi/
pico ~/.config/lxsession/LXDE-pi/autostart
make the contents of that file run chromium fullscreen on startup:
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@xset s off
@xset -dpms
@xset s noblank
@/usr/bin/chromium-browser --kiosk --disable-infobars --disable-session-crashed-bubble --no-first-run http://localhost:3000
Make the server and irexec run on boot by adding to rc.local
sudo pico /etc/rc.local
add before exit 0
cd /home/pi/lirc-example/server && /usr/bin/python -m SimpleHTTPServer 3000 &
(sleep 3;
sudo -u pi irexec -d
)&
It should boot into the tiny python server and you should be able to see the javascript keycodes displayed by clicking the remote.
lirc
- Testing if remote works: https://discourse.osmc.tv/t/how-to-check-if-the-ir-remote-control-works-gpio/6423/3
- Lirc help: OpenELEC/OpenELEC.tv#3908
- Best lirc config how to that I found: https://learn.adafruit.com/using-an-ir-remote-with-a-raspberry-pi-media-center/configure-and-test
- More tips: https://wiki.ubuntu.com/LircHowto
xdotool
irexec