Thank you for your donation!


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


IR Remote Control with Lirc
#17
the attached beginners how-to collates the steps from this thread and should work to give a running remote....

well for some odd reason I can't add the attachment so here it is in full form...(mods please fix Smile )

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..(you don't use the usb dongle)
https://www.amazon.com/Xbox-DVD-Remote-C...B000OCZU0Y

Code:
Code:
sudo apt-get update
sudo apt-get install -y lirc


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/lirc0


Reboot...

If all went well you should now have a lirc device. Verify this by issuing the following command:
Code:
ls /dev/lirc0


This command should return a file named lirc0 . 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/lirc0

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
----------
bob
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: