Today I had some free time… so I decided to use my favorite gadget for something.
A fellow blogger mentioned to me that I should use a Pi and a Kymera wand to get the Pi to control things… like magic.
I decided to use another IR remote to ‘pair’ with the RPi and then map the wand to the buttons on t’other remote.
BOM:
IR receiver - http://www.adafruit.com/product/157
Kymera wand/IR remote - http://www.adafruit.com/products/389
- Install LIRC (Linux Infrared Remote Control - basically the handler for the remote)
sudo apt-get install lirc liblircclient-dev
- Setup the receiver
sudo nano /etc/modules
Insert into the bottom of this file:
lirc_dev
lirc_rpi gpio_in_pin=18
Exit the file.
sudo nano /etc/lirc/hardware.conf
Make it look exactly like this:
# /etc/lirc/hardware.conf
Arguments which will be used when launching lircd
LIRCD_ARGS="–uinput"
Don’t start lircmd even if there seems to be a good config file
START_LIRCMD=false
Don’t start irexec, even if a good config file seems to exist.
START_IREXEC=false
Try to load appropriate kernel modules
LOAD_MODULES=true
Run “lircd –driver=help” for a list of supported drivers.
DRIVER=“default”
usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0" MODULES=“lirc_rpi”
Default configuration files for your hardware if any
LIRCD_CONF="" LIRCMD_CONF="" Exit the file.
- Reboot to save the changes
- Wire up the receiver! (from Adafruit website) Pin 1 goes to GPIO 18, pin 2 goes to GND and pin 3 goes to 5v.
sudo /etc/init.d/lirc stop
mode2 -d /dev/lirc0 Now press some buttons on your remote whilst pointing it at the receiver. You should see stuff happening when you press buttons.
- Now you need to record the signals that the remote sends
irrecord -d /dev/lirc0 ~/lircd.conf
Just follow the instructions, they are very clear. - Copy the configuration file to where lirc is looking for it
sudo cp lircd.conf /etc/lirc/lircd.conf
- Restart lirc
sudo /etc/init.d/lirc restart
- You can now test that the buttons are working!
irw
- Now install lirc for Python
sudo easy_install python-lirc
- Download and run the test file I’ve written
wget http://github.com/xavbabe/pi_scripts/IR/ir_test.py python ir.py
Now press buttons on your remote, you should now see them coming up on your screen! - You must now create the file /etc/lirc/lirc rc and put into it:
begin button = KEY_UP prog = myprogram config = up end
You must add entries like this for every of the buttons you u set up using irrecord
.
13 Map your Kymera wand (optional)
Put the wand into ’learning’ mode (point upwards and double tap)
Carefully aim it towards and do the control that you want to use. Then, when it has started pulsing rapidly, aim it at the other remote and press the button you want to use on the other remote. Repeat for all the buttons you want to use!
After this, point the wand down and double tap, you are now ready to use it!
To take it a bit further, I would like to make the Python script control other things, like lighting in the house (rather simple idea!).
Hope you found this useful!