The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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


Messages In This Thread
IR Remote Control with Lirc - by FizzyTea - 05-16-2018, 04:56 PM
RE: IR Remote Control with Lirc - by FizzyTea - 05-16-2018, 05:00 PM
RE: IR Remote Control with Lirc - by remy1961 - 05-16-2018, 09:11 PM
RE: IR Remote Control with Lirc - by FizzyTea - 05-16-2018, 10:14 PM
RE: IR Remote Control with Lirc - by CallMeMike - 07-05-2023, 09:53 AM
RE: IR Remote Control with Lirc - by CallMeMike - 07-06-2023, 10:52 AM
RE: IR Remote Control with Lirc - by DRONE7 - 05-17-2018, 01:17 AM
RE: IR Remote Control with Lirc - by remy1961 - 05-17-2018, 03:37 AM
RE: IR Remote Control with Lirc - by Tim Curtis - 05-17-2018, 10:19 PM
RE: IR Remote Control with Lirc - by FizzyTea - 05-17-2018, 09:06 AM
RE: IR Remote Control with Lirc - by mezcal - 07-22-2018, 05:08 AM
RE: IR Remote Control with Lirc - by FizzyTea - 07-22-2018, 11:05 AM
RE: IR Remote Control with Lirc - by DRONE7 - 09-12-2018, 04:30 AM
RE: IR Remote Control with Lirc - by FizzyTea - 09-12-2018, 10:42 AM
RE: IR Remote Control with Lirc - by stosoorok - 10-21-2018, 03:05 PM
RE: IR Remote Control with Lirc - by frengo - 12-12-2018, 11:26 PM
RE: IR Remote Control with Lirc - by rh2018 - 12-24-2018, 12:07 PM
RE: IR Remote Control with Lirc - by stosoorok - 02-27-2019, 07:51 PM
RE: IR Remote Control with Lirc - by DRONE7 - 12-12-2018, 11:46 PM
RE: IR Remote Control with Lirc - by frengo - 12-13-2018, 01:05 AM
RE: IR Remote Control with Lirc - by DRONE7 - 12-13-2018, 05:57 AM
RE: IR Remote Control with Lirc - by rh2018 - 12-16-2018, 08:18 AM
RE: IR Remote Control with Lirc - by Cardone - 12-13-2018, 09:25 AM
RE: IR Remote Control with Lirc - by frengo - 12-14-2018, 11:52 PM
RE: IR Remote Control with Lirc - by DRONE7 - 12-15-2018, 01:24 AM
RE: IR Remote Control with Lirc - by frengo - 12-15-2018, 07:42 AM
RE: IR Remote Control with Lirc - by DRONE7 - 12-16-2018, 09:22 AM
RE: IR Remote Control with Lirc - by rh2018 - 12-16-2018, 12:24 PM
RE: IR Remote Control with Lirc - by dezotrk - 03-13-2019, 03:46 PM
RE: IR Remote Control with Lirc - by DRONE7 - 03-13-2019, 06:15 PM
RE: IR Remote Control with Lirc - by dezotrk - 03-15-2019, 06:45 PM
RE: IR Remote Control with Lirc - by IT-Andy52 - 03-18-2019, 11:07 AM
RE: IR Remote Control with Lirc - by DRONE7 - 03-19-2019, 02:21 AM
RE: IR Remote Control with Lirc - by IT-Andy52 - 03-19-2019, 09:05 AM
RE: IR Remote Control with Lirc - by DRONE7 - 03-19-2019, 09:40 AM
RE: IR Remote Control with Lirc - by rikardo1979 - 04-15-2019, 12:34 PM
RE: IR Remote Control with Lirc - by Cardone - 04-15-2019, 01:11 PM
RE: IR Remote Control with Lirc - by rikardo1979 - 04-15-2019, 01:21 PM
RE: IR Remote Control with Lirc - by Cardone - 04-15-2019, 02:02 PM
RE: IR Remote Control with Lirc - by rikardo1979 - 04-16-2019, 10:19 AM
RE: IR Remote Control with Lirc - by stosoorok - 04-17-2019, 06:37 PM
RE: IR Remote Control with Lirc - by remy1961 - 04-19-2019, 06:22 PM
RE: IR Remote Control with Lirc - by rikardo1979 - 04-19-2019, 06:49 PM
RE: IR Remote Control with Lirc - by TookaFace - 06-02-2019, 05:22 PM
RE: IR Remote Control with Lirc - by fedormil - 02-23-2020, 05:02 AM
RE: IR Remote Control with Lirc - by burph - 04-04-2020, 12:24 PM
RE: IR Remote Control with Lirc - by waffle - 04-26-2020, 05:41 PM
RE: IR Remote Control with Lirc - by KmPan - 02-07-2021, 03:45 AM
RE: IR Remote Control with Lirc - by gregvds - 03-09-2021, 03:25 PM
RE: IR Remote Control with Lirc - by mmcsn - 03-10-2021, 02:29 PM
RE: IR Remote Control with Lirc - by mmcsn - 03-10-2021, 02:50 PM
RE: IR Remote Control with Lirc - by KmPan - 03-28-2021, 04:49 AM
RE: IR Remote Control with Lirc - by mmcsn - 03-10-2021, 10:54 PM
RE: IR Remote Control with Lirc - by donutswdad - 03-27-2021, 01:21 AM
RE: IR Remote Control with Lirc - by waffle - 04-04-2023, 06:37 PM

Forum Jump: