Easy Setup IR Remote Control Using LIRC for the Raspberry PI (RPi) - July 2019 [Part 2]

In Part 1 I demonstrated how to assemble the RPi + VS1838b and configure Raspbian's LIRC module to receive IR commands from an IR remote. All hardware and LIRC setup issues are discussed in part 1. Part 2 will demonstrate how to interface the [hardware + LIRC module we setup in Part 1] with python.

--------------Part 1------------------------------------|-----Part 2----

Remote <---->IR Receiver + Rpi <---> LIRC <---> Python

Supplies:

none

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Hide Devinput.lircd.conf

Your remote configuration file(s) will be placed in the /etc/lirc/lircd.conf.d directory. LIRC will find any file in this directory as long as it has a .conf extension (ie: JVC.lircd.conf). We will not be using the devinput.lircd.conf file so we will hide it by changing the extension as follows by renaming devinput.lircd.conf to devinput.lircd.conf.copy

$ sudo mv /etc/lirc/lircd.conf.d/devinput.lircd.conf /etc/lirc/lircd.conf.d/devinput.lircd.conf.copy

Step 2: Download .conf File for Your Remote

By far the easiest way to obtain a remote .conf file is to download it from the huge library at lirc.sourceforge.net Even if your particular remote model is not listed it is VERY likely that another model from the same manufacturer will work fine. Just find the manufacturer of your remote and click on a model that is close. If you are unsure which model is close you can look at the contents of each model and find one that is close to yours.

The hard way to get a .conf file is to create your own using the built in tool irrecord but I was VERY unsuccessful trying to create a file using this utility despite much effort. There are lots of other folks with similar difficulties using irrecord and I highly recommend the easy route of downloading a .conf file from lirc.sourceforge.net

Your remote configuration file(s) will be placed in the /etc/lirc/lircd.conf.d directory. LIRC will find any file in this directory as long as it has a .conf extension (ie: JVC.lircd.conf).

Step 3: Python Code

Here is some code to test.

from lirc import RawConnection

def ProcessIRRemote(): #get IR command #keypress format = (hexcode, repeat_num, command_key, remote_id) try: keypress = conn.readline(.0001) except: keypress="" if (keypress != "" and keypress != None): data = keypress.split() sequence = data[1] command = data[2] #ignore command repeats if (sequence != "00"): return print(command)

#define Global conn = RawConnection()

print("Starting Up...")

while True:

ProcessIRRemote()

Be the First to Share

    Recommendations

    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest

    6 Discussions

    0
    None
    Rich101101

    4 weeks ago

    Remote configuration file(s) are placed in the /etc/lirc/lircd.conf.d directory. LIRC will find any file in this directory as long as it has a .conf extension (ie: JVC.lircd.conf).

    I have not used LIRC to send commands but the only change would be to add python code to send and receive. The following link should point you in the right direction. http://lirc.org/api-docs/html/group__sending.html

    0
    None
    Mous2890Rich101101

    Reply 4 weeks ago

    Hi,

    Can I have a bit more information on transmitting signals? I want to send a Signal from my Pi to my Samsung TV to mute and then unmute? There is a brief mention in Part 1 of configuring the transmitter but isnt in great detail.

    Also, when i download the conf file for my remote, do i place it in /etc/lirc/lircd.conf.d/? if yes, what should it be named?

    Your help on this would be much appreciated! Thanks.

    0
    None
    Rich101101Mous2890

    Reply 4 weeks ago

    Remote configuration file(s) are placed in the /etc/lirc/lircd.conf.d directory. LIRC will find any file in this directory as long as it has a .conf extension (ie: JVC.lircd.conf).

    I have not used LIRC to send commands but the only change would be to add python code to send and receive. The following link should point you in the right direction. http://lirc.org/api-docs/html/group__sending.html

    0
    None
    Mous2890Rich101101

    Reply 5 weeks ago

    Ok great, just seen these. Trying it all out now :)

    0
    None
    Mous2890

    5 weeks ago

    Hi,

    Can we get a bit more information about the hardware setup? Maybe some closer pics of the parts and where they're connected. Will certainly help.

    Will be looking to try this tonight after work :)