Objective

In this project, we will connect an Infrared remote command receiver to Raspberry Pi. Later on an IR remote controller central is pushed, Raspberry Pi will decode the signal and display the cardinal code on the terminal.

This project used a IR receiver library called LIRC. We also have a simple programming tutorial which does not require LIRC library.  Hither is the link: https://osoyoo.com/2021/05/26/use-basic-gpio-library-to-get-ir-remote-code-no-need-lirc/

Parts:

one pc Raspberry Pi 2/3/nil 10 1 raspi
1 pc 8GB MicroSD memory carte x 1preinstalled Raspbian Os. 8gtf
1 pc VS1838B x 1 LACC200613
i pc Infrared Remote Controller 10 1 LACC200612
1 pc breadboard x 1 BREADBOARD
1 pc GPIO breakout kit(optional) breakout
some Jumper Wires LACC2006AD-31

Circuit Connection Graph

vs1838Ba

Install lirc library

LIRC (Linux Infrared remote control)is an open source library which permit linux to decode IR indicate

sudo apt-get install lirc

change configuration with nano command

sudo nano /etc/lirc/hardware.conf

meliorate post-obit contents in /etc/lirc/hardware.conf file

LIRCD_ATGS=""

Driver="default"

DEVICE="/dev/lirc0"

MODULES="lirc-rpi

Edit module file with nano

sudo nano /etc/modules

add post-obit ii lines in the end of  /etc/modules添加完两行后按ctrl+o 保存修改,按ctrl+x退出

lirc-dev

lirc-rpi gpio_in_pin_eighteen gpio_out_pin_17

GPIO 18 pivot will get input data from IR receiver

Raspberry Pi GPIO pin graph:

Restart the raspberry pi to enable configuration:

reboot

restart lirc by running followingcommand

sudo /etc/init.d/lirc restart

Exam IR receiver

one)Stop lirc by running:

sudo /etc/init.d/lirc finish

2)run following code

mode2 –d /dev/lirc0

After running in a higher place control, terminal might show following errors:

This ways  /lirco module has non be installed under /dev diretory .

To fix it, y'all need uncomment "#dtoverlay=lirc-rpi" in /boot/config.txt file

sudo nano /kicking/config.txt

find #dtoverlay=lirc-rpi and remove the "#" sign, printing ctrl-x to save and exit.

Reboot and test once again with following two commands:

reboot

mode2 -d /dev/lirc0

If no error shows up after running higher up commands, yous can press keys in the IR remoter control. You will come across following effect:

press ctrl-c to go out

Record IR code by running post-obit ii commands:

sudo /etc/init.d/lirc stop

irrecord –listnamespace

write down the key names every bit following:

KEY_CHANNELDOWN

KEY_CHANNELUP

KEY_CHANNEL

KEY_PREVIOUS

KEY_NEXT KEY_PLAY

KEY_VOLUMEDOWN

KEY_VOLUMEUP

KEY_EQUAL

KEY_NUMERIC_0 ~ KEY_NUMERIC_9

Run IR lawmaking record control:

irrecord -d /dev/lirc0 ~/lircd.conf

go on press Render key until yous see "Press Render now to start recording.".
Printing RETURN AGAIN ,then press each cardinal  quickly as per the education in the screen.  Each press will evidence upward a dot sign in the screen. Afterward the dots fill 2 lines, screen will prompt: "Please enter the name for the adjacent push button (press to finish recording)", then press the key you want to record..
Case : enter KEY_PLAY  and return, screen prompt "Now hold down button "KEY_PLAY", press and hold PLAY key in your IR controller, PI will record the key code and prompt "Please enter the name for the adjacent push (press to stop recording)"… repeat the procedure until all your keys are recorded, save the config file to lircd.conf

Finally replace /etc/lirc/lircd.conf file with your lircd.conf file :

sudo cp ~/lircd.conf /etc /lirc/lircd.conf

restart lirc and test IR keys with following 2 commands:

sudo /etc/init.d/lirc get-go

irw

Afterwards you printing keys in the IR controller, Pi will display key codes equally following:

You lot might feel that LIRC library installation and configuration is a footling bit complicated. If you don't want to use LIRC library, nosotros have another simple solution to program IR receiver with basic GPIO functions. Here is the link: https://osoyoo.com/2021/05/26/utilise-basic-gpio-library-to-go-ir-remote-code-no-need-lirc/