[How to do instruction] IR remote control without LIRC - Printable Version +- Moode Forum (https://moodeaudio.org/forum) +-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3) +--- Forum: FAQ and Guides (https://moodeaudio.org/forum/forumdisplay.php?fid=9) +--- Thread: [How to do instruction] IR remote control without LIRC (/showthread.php?tid=3584) |
IR remote control without LIRC - mmcsn - 03-11-2021 Hi everyone! TDLR: How to set up an infrared receiver, add/configure a remote and program the keys to control MoodeAudio without using LIRC. I wanted to control my moodeaudio using a remote control and so far I've been using LIRC so after the last kernel updates it got so messy to set-it up that I just gave up on it. Personally, I'm much happier with this new solution however but please bare in mind that I'm a complete newbie with python and any help to improve what I'm sharing below is much appreciated. I might have forgotten to document something on the way, if so please let me know and I'll update the original thread. Credits: This is based mainly on Lime-Parallelogram work and she goes through it in detail in this video. My hardware: Raspberry pi 4 A generic remote control IR sensor TL1838 - 3 - Left - Out - GPIO 17 or pin 11 (you can use other GPIO but make sure to check the pin number) - 2 - Middle - GND - pin 9 - 1 - Right - VCC 3.3v - pin 1 1 - Connect the sensor to the raspberry 2 - Set up the gpio and install dependencies Code: sudo apt install python3-gpiozero Edit /boot/config.txt Code: sudo nano /boot/config.txt add Code: dtoverlay=gpio-ir,gpio_pin=17 Reboot 3. Decode the remote(s) you wanna use get the files and run the program Code: git clone https://github.com/Lime-Parallelogram/IR-Code-Decoder-- You'll be asked to set the sensor pin. use the pin number (not GPIO number) in this case pin 11. Add a name for the remote (anything you want) and start adding keys. Once you're done there will be a txt file with the remote name. open this file (e.g. nano remote.txt) and copy those values to some notepad. 4. Prepare the python script download the script from Lime-Parallelogram Code: cd ~ edit the script Code: nano ir-scrypt.py firstly add the following line 'import subprocess' at the top of the script Code: #Imports modules next, replace the list in the variables Buttons and ButtonsNames for the HEX codes and names you set up in your remote on step 3. In my case my remote has 5 buttons so I got in my txt; Quote:Button Code - enter: 0x3482c20dfL therefore my variables in the script will become Code: Buttons = ["0x3482c20dfL","0x3482c40bfL","0x3482cc03fL","0x3482ca05fL","0x3482c609fL"] you can save it and confirm working by running it Code: python ir-scrypt.py when pressing the buttons you should get the button name output. 4. Make the script control MPC going back to our script (nano ir-scrypt.py) look for this code right in the end while True: Code: inData = convertHex(getBinary()) #Runs subs to get incomming hex value just after this, we can add some conditions to control MPC in moodeaudio. Probably there are much better ways how to tackle this. I managed to make it work by using conditions. Here's my example: Code: while True: If you want more buttons just copy the elif and the line after it. List of MPC commands you can change the subprocess.call as you see fit. You can test and run it again 'python ir-scrypt.py'. 4. Make the scrypt run on boot You can replace my_python for name: Code: sudo nano /lib/systemd/system/my_python.service If your script is at the same location as above, when it was created then paste the code below otherwise adjust the location: Code: [Unit] then run Code: systemctl daemon-reload you can reboot and the service should start. I hope it works as well for you as it did for me RE: IR remote control without LIRC - donutswdad - 03-27-2021 Works great!! Thanks so much for posting this as the other lircd methods did not work for me either using an Apple A1294 remote with 7.1. RE: IR remote control without LIRC - donutswdad - 04-28-2021 I used the PiIR library to make a version of your script that barely uses any CPU and is much simpler. PiIR requires the use of python3, so it can still be used along side your guide except change the references from "python" to "python3". Thought I would share it with everyone. Code: from piir.io import receive RE: IR remote control without LIRC - Larvitar - 06-08-2021 I wrote a simple project lately for IR remote control. It provides a simple configuration interface, has extensive configuration and supports Spotify. https://github.com/Larvitar/MoodeIrRemote RE: IR remote control without LIRC - mmcsn - 09-04-2021 (06-08-2021, 09:40 PM)Larvitar Wrote: I wrote a simple project lately for IR remote control. It provides a simple configuration interface, has extensive configuration and supports Spotify. This is beautiful. I now use it, its so much better Thank you! RE: IR remote control without LIRC - Pixxel - 10-04-2021 (06-08-2021, 09:40 PM)Larvitar Wrote: I wrote a simple project lately for IR remote control. It provides a simple configuration interface, has extensive configuration and supports Spotify. Hi, The IR remote control works, but only for a while. When I don't use the IR remote control for a few minutes, it doesn't work until I adjust the volume in the GUI Moode player. It is as if the system has put the process to sleep or something. What could be wrong? |