Make sure you have mpc installed - sudo apt-get install mpc
Setting up for Stretch is slightly different to the instructions for PiMusicbox.
sudo apt-get update
sudo apt-get install lirc
Add or amend the following lines to /etc/modules
sudo nano /etc/modules
lirc_dev
lirc_rpi gpio_in_pin=18
Add or amend following in /etc/lirc/hardware.conf
sudo nano /etc/lirc/hardware.conf
# /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=""
Amend or add to /boot/config.txt
sudo nano /boot/config.txt
dtoverlay=lirc-rpi
dtparam=gpio_in_pin=18
Amend or add to /etc/lirc/lirc_options.conf
sudo nano /etc/lirc/lirc_options.conf
driver = default
device = /dev/lirc0
Stop and restart lirc to pick up changes
sudo /etc/init.d/lircd stop
sudo /etc/init.d/lircd start
Check lirc is running
sudo /etc/init.d/lircd status
sudo reboot
Testing the IR receiver is relatively straightforward.Run these two commands to stop lircd and start outputting raw data from the IR receiver:
sudo /etc/init.d/lircd stop
sudo /etc/init.d/lircd stop
mode2 -d /dev/lirc0
Point a remote control at your IR receiver and press some buttons.
You should see something like this on your screen:
You should see something like this on your screen:
space 16300
pulse 95
space 28794
pulse 80
space 19395
pulse 83
space 402351
pulse 135
space 7085
pulse 85
space 2903
ctrl & c to exit.
If there is no reaction, check the receiver is connected, that you have battery in remote and run through previous steps again.
Setting up config for remote (Skip if using Keyes Remote)
If you are using your own remote have a look at LIRC first to see if it's listed there.If not, it's a simple process to use irrecord to record your own.
sudo /etc/init.d/lircd stop
sudo irrecord -d /dev/lirc0 ~/lircd.conf
Follow the instruction gived by the above command carefully, at the end a ~/lircd.conf file will be generated.
Backup the original lircd.conf
sudo mv/etc/lirc/lircd.conf /etc/lirc/lircd_original.conf
Copy the recorded lircd.conf over
sudo cp ~/lircd.conf /etc/lirc/lircd.conf
Reboot or restart lirc
sudo reboot or sudo /etc/init.d/lircd start
If using Keyes brand of remote control.
This config file is just for the Keyes brand of remote control
Open the lircd config file, delete any existing info,
copy & paste details below between the #############
Due to formatting on here you may need to jiggle it around a bit.
sudo nano /etc/lirc.lircd.conf
########################################################################## 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 19 10:13:19 2014
# contributed by
# brand: KEYES
# model no. of remote control:
# devices being controlled by this remote:
begin remote
name KEYES
bits 16
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 9281 4484
one 622 1657
zero 622 513
ptrail 622
repeat 9241 2236
pre_data_bits 16
pre_data 0xFF
gap 109259
toggle_bit_mask 0x0
begin codes
KEY_VOLUMEUP 0x629D
KEY_VOLUMEDOWN 0xA857
KEY_PREVIOUSSONG 0x22DD
KEY_NEXTSONG 0xC23D
KEY_PAUSE 0x02FD
KEY_1 0x6897
KEY_2 0x9867
KEY_3 0xB04F
KEY_4 0x30CF
KEY_5 0x18E7
KEY_6 0x7A85
KEY_7 0x10EF
KEY_8 0x38C7
KEY_9 0x5AA5
KEY_0 0x4AB5
KEY_SHUFFLE 0x42BD
KEY_NUMERIC_POUND 0x52AD
end codes
end remote
#########################################################################
Save and close it.
To ensure changes have been picked up stop and restart lirc
sudo /etc/init.d/lircd stop
sudo /etc/init.d/lircd start
Point controller at receiver, press buttons, each button should now give it's name on screen.
You may need to type irw first before you get a response - if both ways don't give results something else is wrong.
Decide what each button will do.
This is where you decide what each key will do. To assign what the keys actually run you need a new config file.prog = irexec button = KEY_NEXTSONG config = mpc next end begin prog = irexec button = KEY_PREVIOUSSONG config = mpc prev end begin prog = irexec button = KEY_NUMERIC_POUND config = shutdown –h now end begin prog = irexec button = KEY_SHUFFLE config = mpc shuffle end begin prog = irexec button = KEY_VOLUMEUP config = mpc volume +10 end begin prog = irexec button = KEY_VOLUMEDOWN config = mpc volume -10 end # insert your playlist name between the " " begin prog = irexec button = KEY_1 config = mpc stop; mpc clear; mpc load "Chef";mpc play; endYou will see all the operations are done using mpc a full list of options is heresudo nano /root/.lircrc and here sudo nano /home/pi/.config/lircrc as I can't remember which one it is then copy and paste all the text between the lines.
---------------------------------------------------------------------------------------------------------------------
begin prog = irexec button = KEY_PAUSE config = mpc toggle endbegin
begin prog = irexec button = KEY_2 config = mpc stop; mpc clear; mpc load "Your playlist here";mpc $ end begin
prog = irexec button = KEY_3 config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play; end begin prog = irexec button = KEY_4 config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play; end begin prog = irexec button = KEY_5 config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play; end begin prog = irexec button = KEY_6 config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play; end begin prog = irexec button = KEY_7 config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play; end begin prog = irexec button = KEY_8 config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play; end begin prog = irexec button = KEY_9 config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play; end begin prog = irexec button = KEY_0 config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play; end ------------------------------------------------------------------------------
To start on boot use
sudo systemctl enable lirc
to start irexec on boot use make the amendment to /etc/rc.localsudo nano /etc/rc.localpaste this line near the end, but above the last linesudo -u pi irexec -dsave it and Sudo Reboot Good luckhttp://www.lirc.org/
Thanks to
https://gist.github.com/prasanthj/c15a5298eb682bde34961c322c95378b
https://raspberrypi.stackexchange.com/questions/6974/how-can-i-determine-which-os-image-i-am-running
https://www.justboom.co/tutorials/configure-justboom-ir-remote-lirc/
No comments:
Post a Comment