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

After much searching I was surprised and dismayed about the conflicting information on how to setup IR remote control for my RPi project. I thought it would be easy but setting up Linux InfraRed Control (LIRC) has been problematic for a long time but much changed in June 2019 with the release of the Buster version of Raspbian making much of the tutorials out there worthless. Many tutorials have you create a hardware.conf file but LIRC does not need nor want it and the lirc-rpi module has been replaced with the gpio-ir module.

The tutorial assumes the RPi is running raspbian (version Buster Jun 2019). Also a working knowledge of the terminal, basic commands from the command prompt and editing text files is assumed.

Goal: To enable IR remote control of RPi projects

1) Setup LIRC on RPi [Part 1]

2) Demonstrate LIRC using python [Part 2]


Supplies:

--- Raspberry Pi (3,4,zero)

--- Dupont wire (female-female)

--- VS 1838b IR receiver

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: Assemble Hardware

Using the VS1838b IR receiver couldn't be easier. Just hook up the sensor to the RPi directly with Dupont wire (Female-Female). You could also use a breadboard (not shown) or solder on a protoboard (photo)

Looking at the VS1838b IR Receiver from the front (with the big X facing you)

---- Left leg is out

---- Center leg is ground

---- Right leg is 3.3v

1) Attach the left leg to BCM pin 17 on the RPi (yellow wire)

2) Attach the center leg to ground (black wire)

3) Attach the right leg to 3.3v (red wire)

Step 2: Install Lirc

1) Open terminal window and install LIRC. Be forewarned that this will likely raise an error "Failed to start Flexible IR remote input/output application support" as the installed files now have .dist appended and the suffix must be removed as noted below. Not hard but frustrating.

$ sudo apt-get update

$ sudo apt-get install lirc

----DON'T WORRY! as this will likely raise an error "Failed to start Flexible IR remote input/output application support" as the .dist suffix needs to be deleted from lirc_options.conf. Just rename the file as shown.

$ sudo mv /etc/lirc/lirc_options.conf.dist /etc/lirc/lirc_options.conf

2) Reinstall lirc now that the lirc_options.conf file has been renamed

$ sudo apt-get install lirc

Step 3: Edit Lirc_options.conf

Edit /etc/lirc/lirc_options.conf as follows by changing these two lines:

:

:

driver = default

device = /dev/lirc0

:

:

Step 4: Perform Move to Remove .dist Suffix From Lircd.conf.dist

Remove suffix .dist from /etc/lirc/lircd.conf.dist

$ sudo mv /etc/lirc/lircd.conf.dist /etc/lirc/lircd.conf

Step 5: Edit Config.txt

Edit /boot/config.txt by adding one line in the lirc-rpi module section as follows. This example assumes the RPi is 'listening' on BCM Pin 17 for the IR receiver but any RPi IO pin can be used. I have not tried it yet but if you want to send commands from the RPi then add and uncomment the 4th line shown below to send IR commands on BCM pin 18

:

:

:

# Uncomment this to enable the lirc-rpi module

#dtoverlay=lirc-rpi

dtoverlay=gpio-ir,gpio_pin=17

#dtoverlay=gpio-ir-tx, gpio_pin=18

:

:

:

Step 6: Check Status and Reboot

1) Stop, start and check status of lircd to ensure there are no errors!

$ sudo systemctl stop lircd.service

$ sudo systemctl start lircd.service

$ sudo systemctl status lircd.service

2) Reboot

$ sudo reboot




Step 7: Test Remote

This step assumes you have have a IR receiver hooked up to your RPi on the pin specified in config.txt.

1) stop LIRCD service and test remote using mode2 command

$ sudo systemctl stop lircd.service

$ sudo mode2 -d /dev/lirc0

3) Point the remote at the receiver and press some buttons. You should see something LIKE this:

:

:

space

pulse

:

:

4) Press Ctrl-C to exit

5) Your IR receiver is setup and ready to proceed to Part 2 and be accessed in python.

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

    Great suggestions! Will expand the instructable to include hardware setup and python interface. Thanks for the feddback!!

    1 reply
    0
    None
    Mous2890Rich101101

    Reply 4 weeks ago

    Yes!! I'll be waiting for this. Thank you.

    1
    None
    George-KC1V

    4 weeks ago

    Hello,

    Nicely done article. Is part 2 available now? I would be very interested in seeing it. I would also be interested in what device you would suggest using as the receive sensor.

    Thanks and best regards,
    George

    1
    None
    Rich101101

    5 weeks ago

    Once configured LIRC works great! If there is intetest I can continue by posting how to easily process the received IR remote commands from python.

    1 reply
    0
    None
    Mous2890Rich101101

    Reply 4 weeks ago

    Hey, thanks for your time in writing all of this up.

    Like you quite rightly said, I recently decided to start looking at how to work with Infrared receivers/transmitters with my Raspberry Pi 3 and haven't had any luck. I started following this tutorial but no luck getting my setup to work (using a HotPi).

    What would make this tutorial complete is:
    Part 1 showing the hardware to buy (infrared sensors for receiver and emitter), wiring it all up, gpio pins to plug into etc. Would be super useful to provide links to parts for both US and UK? Only if possible.
    Part 2 would be this guide which is very well written and comprehensive.
    Part 3 using the IR remote commands with python.

    I really hope you find the time to write up the other parts to this as it would be amazing for my project!

    Thanks again, I appreciate your time and hard work on this.