I/R remote .Raspberry Pi, Snakeoil,MPD, and LIRC
#1
This How-to is for an mpd player (not LMS)...

Hardware for Lirc..... all you need is the I/R receiver...and 3 dupont cables to connect it...
https://www.ebay.ca/itm/5PCS-38-kHz-Remo...Sw0fhXmbbB

With it held legs down and the dome facing you...the left-hand pin is input and connects to Pi Gpio=27 (physical pin=13)  centre pin is Ground (physical pin=14)  and right-hand pin is +3.3v (physical pin=1)

Of course a remote is needed and you've probably got a few about....if your chosen one is not in the Lirc database it can be a real headache making a config file so check here first for a working config... then it's just copy and paste in the appropriate file...
http://lirc-remotes.sourceforge.net/remotes-table.html

I use an xbox dvd remote...A couple of bucks at Vinnies or other charity shops..
https://www.lukiegames.com/official-xbox...ayback-kit

Install Lirc and mpc
Code:
sudo apt-get update
sudo apt-get install -y lirc mpc

Edit /boot/config.txt and add these lines ...(where 'xx' is the gpio pin you use for input... eg gpio_in_pin=27)
Code:
# Enable the lirc-rpi module
dtoverlay=lirc-rpi,gpio_in_pin=xx

Edit /etc/lirc/lirc_options.conf  and make sure that driver and devices lines are changed to:
Code:
driver          = default
device          = /dev/lirc1
Usually Lirc uses /dev/lirc0 though for some as yet mysterious reason it is not working in Snakeoil and after some trial and error I found that /dev/lirc1 is what does work.
If your install won't work with /dev/lirc1 then try /dev/lirc0.

Reboot...

If all went well you should now have a lirc device. Verify this by issuing the following command:
Code:
ls /dev/lirc1
or ls /dev/lirc0 if that is what you used earlier.
This command should return a file named lirc0 or lirc1. If this command doesn’t output go back and verify the configuration once again as the drivers have not been loaded.

Test the IR remote and Receiver to verify that the IR receiver is working as expected:
Code:
sudo systemctl stop lircd

mode2 -d /dev/lirc1
Point the remote control at the IR receiver and press its buttons. If the IR receiver is configured successfully you will see output similar to this:

space 3662230
pulse 2428
space 594
pulse 1201
space 596
pulse 1230
space 595
pulse 1209
space 590
pulse 1204
(CTRL+C to stop output and return to command line)

Paste your remote config file from the LIRC database into ..
Code:
sudo nano /etc/lirc/lircd.conf.d/lircd.conf

and reboot.

You can now check for the presence of the services and modules with commands...
Code:
dmesg | grep lirc
 ls -l /dev/lirc0
 ps aux | grep lirc
At this point you can test the configuration created by running :
Code:
irw
Point the remote control to the  IR sensor and press some of the buttons, you should get an output similar to this (if using an xbox dvd remoteSmile
0000000000559aa6 03 KEY_UP Microsoft_Xbox
000000000051cae3 00 KEY_FORWARD Microsoft_Xbox
000000000053cac3 00 KEY_INFO Microsoft_Xbox

This means that the remote is correctly mapped and all should be working fine.
All that is left to do is setup irexec as a service and create a file with the commands irexec should run upon button presses.
Set irexec up as a user service for better security rather than having it run as root.
 
Code:
sudo systemctl edit irexec

and add....
Code:
[Service]
User=pi
Group=pi

then set up the remote's key mapping...
Code:
sudo nano /etc/lirc/irexec.lircrc
and add for your remote....the format is quite simple as this example for the xbox dvd remote shows.
Key presses will then cause mpc to run the commands to control mpd.
I have mapped several Webstreams to the number buttons and included a shutdown and reboot....
Code:
begin
prog = irexec
button = KEY_SELECT
config = mpc toggle
end
begin
prog = irexec
button = KEY_RIGHT
config = mpc next
end
begin
prog = irexec
button = KEY_LEFT
config = mpc prev
end
begin
prog = irexec
button = KEY_PLAY
config = mpc play
end
begin
prog = irexec
button = KEY_PAUSE
config = mpc pause
end
begin
prog = irexec
button = KEY_STOP
config = mpc stop
end
begin
prog = irexec
button = KEY_1
config = mpc clear; mpc add http://5.152.208.98:8058; mpc play
end
begin
prog = irexec
button = KEY_2
config = mpc clear; mpc add http://psn1.prostreaming.net:8095/stream; mpc play
end
begin
prog = irexec
button = KEY_3
config = mpc clear; mpc add http://radionz-ice.streamguys.com:80/national.mp3; mpc play
end
begin
prog = irexec
button = KEY_4
config = mpc clear; mpc add http://178.33.232.106:8014/stream; mpc play
end
begin
prog = irexec
button = KEY_5
config = mpc clear; mpc add http://streaming.radionomy.com/acidbarrett?lang=en-US%2cen%3bq%3d0.5; mpc play
end
begin
prog = irexec
button = KEY_6
config = mpc clear; mpc add http://206.217.213.16:8430/; mpc play
end
begin
prog = irexec
button = KEY_7
config = mpc clear; mpc add http://rock70s.stream.ouifm.fr/ouifmseventies.mp3; mpc play
end
begin
prog = irexec
button = KEY_8
config = mpc clear; mpc add http://rock60s.stream.ouifm.fr/ouifmsixties.mp3; mpc play
end
begin
prog = irexec
button = KEY_8
config = mpc clear; mpc add http://rock60s.stream.ouifm.fr/ouifmsixties.mp3; mpc play
end
begin
prog = irexec
button = KEY_9
config = mpc clear; mpc add http://streaming.radionomy.com/feelingtheblues?lang=en-US%2cen%3bq%3d0.5; mpc play
end
begin
prog = irexec
button = KEY_0
config = mpc clear; mpc add http://streaming.radionomy.com/Peace-Radio?lang=en-US%2cen%3bq%3d0.5; mpc play
end
begin
prog = irexec
button = KEY_TITLE
config = sudo shutdown -h now
end
begin
prog = irex
button = KEY_INFO
config = sudo reboot
end
begin
prog = irexec
button = KEY_UP
config = mpc seek +00:00:10
end
begin
prog = irexec
button = KEY_DOWN
config = mpc seek -00:00:10
end

reboot
and your remote should be up and running Smile
[-] The following 1 user Likes Bromf's post:
  • agent_kith
Reply

#2
Would something like this be possible for LMS too btw?
These sausage stuffers are so awesome I love them.
Reply

#3
(05-Jan-2019, 08:55 PM)AlfredR Wrote: Would something like this be possible for LMS too btw?
Quote:This How-to is for an mpd player (not LMS)
Perhaps try the LMS forums for the appropriate plugins ?
Sorry but the walk-through is mpd ,....
Reply

#4
wondering if something like this would work with a usb ir blaster.
i use one of them with kodi, its an old mce usb ir receiver, would love to be able to use my logitech harmony one remote with snakeoil.
Reply

#5
(22-Oct-2018, 11:00 AM)Bromf Wrote: This How-to is for an mpd player (not LMS)...

Hardware for Lirc..... all you need is the I/R receiver...and 3 dupont cables to connect it...
https://www.ebay.ca/itm/5PCS-38-kHz-Remo...Sw0fhXmbbB

With it held legs down and the dome facing you...the left-hand pin is input and connects to Pi Gpio=27 (physical pin=13)  centre pin is Ground (physical pin=14)  and right-hand pin is +3.3v (physical pin=1)

Of course a remote is needed and you've probably got a few about....if your chosen one is not in the Lirc database it can be a real headache making a config file so check here first for a working config... then it's just copy and paste in the appropriate file...
http://lirc-remotes.sourceforge.net/remotes-table.html

I use an xbox dvd remote...A couple of bucks at Vinnies or other charity shops..
https://www.lukiegames.com/official-xbox...ayback-kit

Install Lirc and mpc
 
Code:
sudo apt-get update
sudo apt-get install -y lirc mpc

Edit /boot/config.txt and add these lines ...(where 'xx' is the gpio pin you use for input... eg gpio_in_pin=27)
 
Code:
# Enable the lirc-rpi module
dtoverlay=lirc-rpi,gpio_in_pin=xx

Edit /etc/lirc/lirc_options.conf  and make sure that driver and devices lines are changed to:
 
Code:
driver          = default
device          = /dev/lirc1
Usually Lirc uses /dev/lirc0 though for some as yet mysterious reason it is not working in Snakeoil and after some trial and error I found that /dev/lirc1 is what does work.
If your install won't work with /dev/lirc1 then try /dev/lirc0.

Reboot...

If all went well you should now have a lirc device. Verify this by issuing the following command:
 
Code:
ls /dev/lirc1
or ls /dev/lirc0 if that is what you used earlier.
This command should return a file named lirc0 or lirc1. If this command doesn’t output go back and verify the configuration once again as the drivers have not been loaded.

Test the IR remote and Receiver to verify that the IR receiver is working as expected:
 
Code:
sudo systemctl stop lircd

mode2 -d /dev/lirc1
Point the remote control at the IR receiver and press its buttons. If the IR receiver is configured successfully you will see output similar to this:

space 3662230
pulse 2428
space 594
pulse 1201
space 596
pulse 1230
space 595
pulse 1209
space 590
pulse 1204
(CTRL+C to stop output and return to command line)

Paste your remote config file from the LIRC database into ..
 
Code:
sudo nano /etc/lirc/lircd.conf.d/lircd.conf

and reboot.

You can now check for the presence of the services and modules with commands...
 
Code:
dmesg | grep lirc
 ls -l /dev/lirc0
 ps aux | grep lirc
At this point you can test the configuration created by running :
 
Code:
irw
Point the remote control to the  IR sensor and press some of the buttons, you should get an output similar to this (if using an xbox dvd remoteSmile
0000000000559aa6 03 KEY_UP Microsoft_Xbox
000000000051cae3 00 KEY_FORWARD Microsoft_Xbox
000000000053cac3 00 KEY_INFO Microsoft_Xbox

This means that the remote is correctly mapped and all should be working fine.
All that is left to do is setup irexec as a service and create a file with the commands irexec should run upon button presses.
Set irexec up as a user service for better security rather than having it run as root.
 
Code:
sudo systemctl edit irexec

and add....
 
Code:
[Service]
User=pi
Group=pi

then set up the remote's key mapping...
 
Code:
sudo nano /etc/lirc/irexec.lircrc
and add for your remote....the format is quite simple as this example for the xbox dvd remote shows.
Key presses will then cause mpc to run the commands to control mpd.
I have mapped several Webstreams to the number buttons and included a shutdown and reboot....
 
Code:
begin
prog = irexec
button = KEY_SELECT
config = mpc toggle
end
begin
prog = irexec
button = KEY_RIGHT
config = mpc next
end
begin
prog = irexec
button = KEY_LEFT
config = mpc prev
end
begin
prog = irexec
button = KEY_PLAY
config = mpc play
end
begin
prog = irexec
button = KEY_PAUSE
config = mpc pause
end
begin
prog = irexec
button = KEY_STOP
config = mpc stop
end
begin
prog = irexec
button = KEY_1
config = mpc clear; mpc add http://5.152.208.98:8058; mpc play
end
begin
prog = irexec
button = KEY_2
config = mpc clear; mpc add http://psn1.prostreaming.net:8095/stream; mpc play
end
begin
prog = irexec
button = KEY_3
config = mpc clear; mpc add http://radionz-ice.streamguys.com:80/national.mp3; mpc play
end
begin
prog = irexec
button = KEY_4
config = mpc clear; mpc add http://178.33.232.106:8014/stream; mpc play
end
begin
prog = irexec
button = KEY_5
config = mpc clear; mpc add http://streaming.radionomy.com/acidbarrett?lang=en-US%2cen%3bq%3d0.5; mpc play
end
begin
prog = irexec
button = KEY_6
config = mpc clear; mpc add http://206.217.213.16:8430/; mpc play
end
begin
prog = irexec
button = KEY_7
config = mpc clear; mpc add http://rock70s.stream.ouifm.fr/ouifmseventies.mp3; mpc play
end
begin
prog = irexec
button = KEY_8
config = mpc clear; mpc add http://rock60s.stream.ouifm.fr/ouifmsixties.mp3; mpc play
end
begin
prog = irexec
button = KEY_8
config = mpc clear; mpc add http://rock60s.stream.ouifm.fr/ouifmsixties.mp3; mpc play
end
begin
prog = irexec
button = KEY_9
config = mpc clear; mpc add http://streaming.radionomy.com/feelingtheblues?lang=en-US%2cen%3bq%3d0.5; mpc play
end
begin
prog = irexec
button = KEY_0
config = mpc clear; mpc add http://streaming.radionomy.com/Peace-Radio?lang=en-US%2cen%3bq%3d0.5; mpc play
end
begin
prog = irexec
button = KEY_TITLE
config = sudo shutdown -h now
end
begin
prog = irex
button = KEY_INFO
config = sudo reboot
end
begin
prog = irexec
button = KEY_UP
config = mpc seek +00:00:10
end
begin
prog = irexec
button = KEY_DOWN
config = mpc seek -00:00:10
end

reboot
and your remote should be up and running Smile
run these commands at end
  1. Code:
    # systemctl start irexec
  2. Run irexec at startup:
    Code:
    # systemctl enable irexec
[-] The following 1 user Likes vinaymoturi's post:
  • Snoopy8
Reply



Bookmarks

Possibly Related Threads…
Thread Author Replies Views Last Post
  OLED display for Snakeoil Raspberry Pi and MPD Bromf 8 4,522 13-Sep-2024, 01:12 PM
Last Post: vinaymoturi
  Snakeoil virtualized (PROXMOX), USB+PCI AUDIO passthrough, USB-DAC! lzyla 3 477 25-Jun-2024, 02:38 PM
Last Post: agent_kith
  DACs And Motherboards Working With Snakeoil agent_kith 34 6,757,273 02-Jan-2022, 04:27 PM
Last Post: Bromf
  IR Blasting - LMS on snakeoil davem 3 1,929 04-Nov-2020, 12:39 PM
Last Post: davem
  Get Mytec Stereo 192 working in Snakeoil agent_kith 1 4,835 08-Aug-2017, 08:25 PM
Last Post: agent_kith



Users browsing this thread:
1 Guest(s)

[-]
Our Sponsors

[-]
Welcome
You have to register before you can post on our site.

Username/Email:


Password:





[-]
Latest Threads
Announcing Snakeoil Measurements 1.3.0
Last Post: hkphantomgtr
Yesterday 09:55 PM
» Replies: 105
» Views: 11375
Howto setup resampling in Logitech Media...
Last Post: Coacharnold
18-Nov-2024 12:06 AM
» Replies: 7
» Views: 5896
Dropping Measurements, Hello High-End.
Last Post: agent_kith
26-Oct-2024 09:02 AM
» Replies: 12
» Views: 525
Very happy to have Sankeoil......! mpd w...
Last Post: run51
24-Oct-2024 05:35 AM
» Replies: 9
» Views: 1738
SO no soundcard detected - RPI Pi4 snake...
Last Post: run51
21-Oct-2024 10:55 PM
» Replies: 4
» Views: 141
download
Last Post: Snoopy8
19-Oct-2024 05:52 AM
» Replies: 1
» Views: 138
Full proces to instal snakeiol 100% work...
Last Post: audioluthier
11-Oct-2024 02:32 AM
» Replies: 9
» Views: 412
A network protocol designed for CAS
Last Post: hkphantomgtr
10-Oct-2024 09:48 PM
» Replies: 0
» Views: 102
CAS with "Single Core"
Last Post: hkphantomgtr
06-Oct-2024 08:32 AM
» Replies: 2
» Views: 143
MPD player not working
Last Post: Snoopy8
27-Sep-2024 11:54 AM
» Replies: 7
» Views: 276

[-]
SnakeoilOS Mission Statement

Our mission is to create a free to use computer OS that is easy to install, intuitive to operate and play music that will connect and engage with you emotionally.

SnakeoilOS gives you the freedom to spend more time on listening, enjoying and exploring music. Wasting time on computers is now a thing of the past! Everything is constantly evolving/improving. Please check back often for updates.

If you like this project, do show your support with a small token donation. All donations collected will be used to run this website, and for purchasing new equipment for the project.


Powered By MyBB, © 2002-2024. Theme © Melroy van den Berg.