Skip to content

Instantly share code, notes, and snippets.

@billpatrianakos
Forked from prasanthj/lirc-pi3.txt
Last active December 16, 2023 19:20
Show Gist options
  • Save billpatrianakos/708e461491b038b6e274448ca7daa154 to your computer and use it in GitHub Desktop.
Save billpatrianakos/708e461491b038b6e274448ca7daa154 to your computer and use it in GitHub Desktop.
Getting lirc to work with Raspberry Pi Zero W (Raspbian Buster)
# Steps to get IR receiver and transmitter from Amazon [1] working on a Raspberry Pi Zero W.
$ sudo apt-get update
$ sudo apt-get install lirc
# Remove this line from /boot/config.txt
dtoverlay=lirc-rpi,gpio_in_pin=18,gpio_out_pin=17
# Add the following lines in /boot/config.txt
dtoverlay=gpio-ir,gpio_pin=23
dtoverlay=gpio-ir-tx,gpio_pin=22
# Create the lirc_options.conf file
$ sudo cp /etc/lirc/lirc_options.conf.dist to /etc/lirc/lirc_options.conf
# Update the following lines in /etc/lirc/lirc_options.conf
driver = default
device = /dev/lirc0
# Reboot the Pi
$ sudo systemctl reboot
# Check to see if you have a lirc0 and lirc1 device (lirc1 if you are using both a receiver AND transmitter)
$ ls -l /dev/lirc0
$ ls -l /dev/lirc1
# Output should look like this
# crw-rw---- 1 root video 252, 0 Jul 31 11:10 /dev/lirc0
# crw-rw---- 1 root video 252, 0 Jul 31 11:10 /dev/lirc1
# Check that the module is loaded (remember that lirc-rpi is deprecated in favor of gpio-ir)
$ lsmod | grep gpio
w1_gpio 3171 0
wire 32947 1 w1_gpio
gpio_ir_recv 3095 0 # <---- That's our receiver
gpio_ir_tx 3569 0 # <---- That's our transmitter
# Test that you can get IR data
$ sudo systemctl stop lircd.service
$ sudo systemctl stop lircd.socket
$ sudo mode2 --driver default --device /dev/lirc0
# Reboot before testing
$ reboot
# To test if lirc driver is working
$ sudo /etc/init.d/lircd stop
$ mode2 -d /dev/lirc0
<press a key in remote and you should see multple lines like below>
pulse 560
space 1706
pulse 535
# to record a custom remote/register a remote device
$ sudo /etc/init.d/lircd stop
$ sudo irrecord -d /dev/lirc0 ~/lircd.conf
# follow the instruction prompted by the above command carefully
# at the end ~/lircd.conf file will be generated
# backup the original lircd.conf
$ sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf
$ sudo cp ~/lircd.conf /etc/lirc/lircd.conf
$ sudo /etc/init.d/lircd start
# you can test if the recorded remote works by
$ irsend SEND_ONCE <device-name> KEY_POWER
$ irsend SEND_ONCE <device-name> KEY_VOLUMEUP
[1] https://www.amazon.com/gp/product/B01E20VQD8/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment