Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


IR Remote Control with Lirc
#1
My Moode experience has really improved since I added an IR remote.

Headless setups are great but if you do not have your interface ready to go (unlocked, opened and connected etc) there is often quite a bit of lag between wanting to do something - like pause the music - and achieving it. Added to this the fact that my amp has no remote means unlocking my tablet and loading the web ui is a little slow for tasks that warrant some immediacy such as mute and volume adjustments. And since my dac (Pifi DAC+ v2.0) has a built in IR receiver the decision was a no brainer and has vastly improved the usability of my system. I used a cheap generic remote like you used to get with car stereos.

The bump to raspbian stretch brings the latest version of lirc which seems to be classed as a disruptive update. As a result many online guides are now outdated and indeed many newer ones seem to include hangover steps from previous versions which are no longer required. This guide seems to point out and drop the unnecessary steps still mentioned in many guides.

In summary

Install lirc

Quote:sudo apt-get install lirc

Edit /boot/config.txt to include

Quote:dtoverlay=lirc-rpi,gpio_in_pin=26

For my built-in IR receiver gpio_in_pin=26 is the correct choice. Adjust as appropriate.

Edit /etc/lirc/lirc_options.conf

Quote:change:   driver = devinput     to    driver = default
change:   device = auto          to   device = /dev/lirc0

Now you must make a config file for your particular remote control.
You can either find a config file online, many remotes are available, or you can use the irrecord program to record the pulses from each button in sequence. It seems the irrecord may be giving problems with stretch but I am using a previously generated working config file so haven't needed to generate one on stretch. So if you can, find a working lircd.conf for your remote. If not give irrecord a go.

Try
Quote:https://sourceforge.net/projects/lirc-remotes/  
or

Quote:sudo irrecord -n -d /dev/lirc0 ~/lircd.conf
and follow instructions?

Anyway now add your remote config file lircd.conf to
Quote:/etc/lirc/lircd.conf.d/

If it is in this directory it can have any name as long as it ends with .conf apparently.

And Reboot.

You can now check for the presence of the services and modules with commands like

Quote:dmesg | grep lirc
lsmod | grep lirc
ls -l /dev/lirc0
ps aux | grep lirc


You can also now (it is probably advisable on initial install) check if lirc is recieving commands using irsend.
Quote:irsend SEND_ONCE you_remote_name some_key_name
should execute without error. 

Most tutorials have a section showing you how to test at this stage.

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.

I am trying to get a handle on the whole systemd services thing but this has worked for me.

I set irexec up as a user service for better security rather than having it run as root.

I added a file irexec.service to /etc/systemd/system/ containing

Quote:[Unit]
Description=LIRC command handler
After=network.target

[Service]
User=pi
Group=pi
Type=forking
ExecStart=/usr/bin/irexec --daemon /home/pi/.lircrc

[Install]
WantedBy=multi-user.target
Wants=lircd.service

Then I create the file of commands specified in irexec.service - /home/pi/.lircrc in this case.
It contains commands of the form

Quote:begin
prog = irexec
button = KEY_VOLUMEUP
config = /var/www/vol.sh up 2
end

begin
prog = irexec
button = KEY_PLAYPAUSE
config = mpc toggle
repeat = 0
end

Now reboot.
Check the status of your services with 

Quote:systemctl status lircd
systemctl status irexec

Now you can control your moOde!

(I have a warning in my systemctl status report for lircd but all works well so I'm ignoring it for now)
Reply
#2
Any comments on the process welcome, particularly any insights or comments on my irexec.service unit file as I am lacking in experience here.

Does anybody have any alternatives to lirc or to IR for controlling remotely?

Also does anybody have any experience adding an IR receiver to an ALLO BOSS DAC as I am considering purchasing one?
Reply
#3
Hi,
I have my moode streamer on RPi 3, allo boss as DAC, and using IR remote.
What do you mean by "adding an IR receiver to an allo boss dac"? The 2 are not linked I think.
Just like you, I can't imagine my moode without an IR remote. If you have unused buttons on the remote, you can link them to a number of playlists you create yourself. I have a remote button for jazz, another for hip-hop, another for classic.
Reply
#4
(05-16-2018, 09:11 PM)remy1961 Wrote: Hi,
I have my moode streamer on RPi 3, allo boss as DAC, and using IR remote.
What do you mean by "adding an IR receiver to an allo boss dac"? The 2 are not linked I think.
Just like you, I can't imagine my moode without an IR remote. If you have unused buttons on the remote, you can link them to a number of playlists you create yourself. I have a remote button for jazz, another for hip-hop, another for classic.

Sorry, yes I was very unclear. I probably just meant are there free gpio pins available? I suppose there must be tech details on the allo site now that I think about it!  Rolleyes

I have my fav radio station assigned to one button. It adds it to the top of the playlist. I also have a button activate a script which gets the current playlist from my other player and adds it. I have a set of volume buttons for fine adjustments and a pair for larger jumps. And it's very easy to add new functionality when you want to.
Reply
#5
Moved to it's own thread as requested.
----------
bob
Reply
#6
Hi DRONE7
I think it will be better if you could put your guide under a separate thread, with a title like "Step by step guide for using IR remote with moOde".
That's because your guide is really a step by step one and if possible put a link to an IR receiver and how to wire it. I used your guide myself and it makes things really easy.

Remy
Reply
#7
My setup works fine. I have read of issues with irrecord but I have none and do not need to use it as I have a working onfiguration for my remote.

My understanding is some of the steps described by DRONE7 are unnecessary now for Stretch. For example the hardware.conf is no longer required and you do not need to edit the /etc/modules any longer.

I did a fresh install of latest moode yesterday and have a fully functional ir setup without a hardware.conf or edited /etc/modules
Reply
#8
(05-17-2018, 03:37 AM)remy1961 Wrote: Hi DRONE7
I think it will be better if you could put your guide under a separate thread, with a title like "Step by step guide for using IR remote with moOde".
That's because your guide is really a step by step one and if possible put a link to an IR receiver and how to wire it. I used your guide myself and it makes things really easy.

Remy

Hi,

Sounds like a good idea.

@DRONE7 can you easily copy/paste your nice post into a new thread or do you need me to do some mod stuff?

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#9
Hello,

I think your post is better then DRONE7s one. I think the line Wants=lircd.service in the service file should be in the [Unit] section.

It is not necessary to create second irexec.service. There is a file /etc/systemd/system/multi-user.target.wants/irexec.service. You can modify it to start as a pi user.
Code:
sudo systemctl edit irexec
Code:
[Service]
User=pi
Group=pi

And the commands will be in the file /etc/lirc/irexec.lircrc. If you need use another command file edit it:
Code:
[Service]
User=pi
Group=pi
ExecStart=
ExecStart=/usr/bin/irexec /home/pi/.lircrc

That s it.
Reply
#10
(07-22-2018, 05:08 AM)mezcal Wrote: Hello,

I think your post is better then DRONE7s one. I think the line Wants=lircd.service in the service file should be in the [Unit] section.

It is not necessary to create second irexec.service. There is a file /etc/systemd/system/multi-user.target.wants/irexec.service. You can modify it to start as a pi user.
Code:
sudo systemctl edit irexec
Code:
[Service]
User=pi
Group=pi

And the commands will be in the file /etc/lirc/irexec.lircrc. If you need use another command file edit it:
Code:
[Service]
User=pi
Group=pi
ExecStart=
ExecStart=/usr/bin/irexec /home/pi/.lircrc

That s it.

Thanks, I'll have a look at this.
Reply


Forum Jump: