So I had a free minute, I will try to use it and tell you how to set up the infrared control of the music center. The one who repeated my design, the IR receiver was definitely highlighted on the front panel PCB board, I used the Chinese VS1838B, but you can install any one with the ability to decode the signal at the 38 kHz carrier frequency. The IR receiver is installed on the board as shown here
If you look closely at the diagram, you can see that the IR receiver is connected to the 37th pin of the RPI Zero system connector, or to GPIO26 pin. To be able to receive IR commands from the remote control, I used LIRC (Linux Infrared Remote Control). As a reminder, I am using the moOde ™ audio player. First, let's go to the console via SSH, for this it is advisable to use a computer with a Linux system or PuTTY for Windows. So in the console, enter:
User: pi Password: moodeaudio
ssh pi@192.168.0.2 (use your device ip address!)
Now let's install LIRC itself:
sudo apt-get update
sudo apt-get install lirc
Next, edit /etc/lirc/lirc_options.conf:
sudo nano /etc/lirc/lirc_options.conf
And we change
change: driver = devinput to driver = default
change: device = auto to device = /dev/lirc0
Now edit /boot/config.txt
dtoverlay = gpio-ir, gpio_pin = 26
It is desirable to already have a configuration file for your console, it looks like this to me. For the $ 1 remote control On the Internet you can find a huge variety of files for various consoles, and of course you can create this file yourself, for this we enter in the console:
sudo irrecord -n -d / dev / lirc0 ~ / lircd.conf
... and follow the instructions. And, by the way, the official site has a detailed instruction.
Lets reboot device:
sudo reboot
Now we edit: /lib/systemd/system/irexec.service adding the process launch from the pi user: (I will give the whole file)
[Unit]
Documentation = man: irexec (1)
Documentation = http: //lirc.org/html/configure.html
Documentation = http: //lirc.org/html/configure.html#lircrc_format
Description = Handle events from IR remotes decoded by lircd (8)
[Service]
user = pi
group = pi
; Hardening opts, see systemd.exec (5). Doesn't add much unless
; not running as root. If these are applicable or not depends on
; what commands irexec.lircrc invokes.
;
; NoNewPrivileges = true
; MemoryDenyWriteExecute = true
; PrivateTmp = true
; ProtectHome = true
; ProtectSystem = full
Type = simple
ExecStart = / usr / bin / irexec /home/pi/.lircrc
; /etc/lirc/irexec.lircrc
[Install]
WantedBy = multi-user.target
And finally, let's create a file /home/pi/.lircrc, which will contain executable commands when you press the buttons on the IR remote control:
begin
prog = irexec
button = KEY_POWER
# config = sudo / sbin / poweroff
config = mpc stop; sudo /var/www/command/restart.sh poweroff
end
begin
prog = irexec
button = KEY_VOLUMEUP
config = /var/www/vol.sh up 1
end
begin
prog = irexec
button = KEY_UP
config = /var/www/vol.sh up 1
end
begin
prog = irexec
button = KEY_VOLUMEDOWN
config = /var/www/vol.sh dn 1
end
begin
prog = irexec
button = KEY_DOWN
config = /var/www/vol.sh dn 1
end
begin
prog = irexec
button = KEY_MUTE
config = /var/www/vol.sh mute
end
The syntax here is very simple, each button (button = KEY_VOLUMEUP) has a corresponding command (config = /var/www/vol.sh up 1). I would like to note that the "KEY_POWER" button works only to turn off device, you need to turn it on with the button on the front panel. I assigned the numeric buttons 0-9 to execute the commands - "mpc play X", where X is the number of the button, and, accordingly, the number of the song in the playlist. Look carefully at my file and you can do almost anything you want!
Rebooting:
sudo reboot
And check:
systemctl status lircd
systemctl status irexec
Now you can control your music center with the IR remote control. By the way, if anyone has interesting ideas on how to do it better, add comments ...
That's all for now, follow my publications on rmicro.ru and on Youtube.
Assembly part 1 Assembly part 2 Assembly part 3 Assembly part 4 Assembly part 5 Assembly part 6