Getting ready

LIRC supports many types of IR detectors, such as Energenie's PiMote IR board; however, since we only need to receive IR signals, we can use a simple (TSOP38238) IR detector:

The three pins of the TSOP38238 IR receiver can fit directly onto the Raspberry Pi header

Install the following packages using the apt-get command:

sudo apt-get install lirc lirc-x  

Add the following to /boot/config.txt. This will enable the driver and define the pin the receiver is fitted on (BCM GPIO24):

dtoverlay=lirc-rpi,gpio_in_pin=23  

Perform a restart of the Raspberry Pi so that the configuration takes effect:

sudo reboot  

We should now find that the IR device is located at /dev/lirc0. We can observe the output of the receiver if we point a remote control at it and press some buttons after using the following command (use Ctrl + Z to exit):

mode2 -d /dev/lirco0    
The lirc0 resource may report as busy:

mode2: could not open /dev/lirc0

mode2: default_init(): Device or resource busy

Then we will need to stop the lirc service:
sudo /etc/init.d/lirc stop

It will give the following response:
[ ok ] Stopping lirc (via systemctl): lirc.service

When you are ready, you can start the service again:
sudo /etc/init.d/lirc start

This will give the following response:
[ ok ] Starting lirc (via systemctl): lirc.service

You will see output similar to the following (if not, ensure that you have connected the receiver connected to the correct pins on the Raspberry Pi GPIO):

space 16300
pulse 95
space 28794
pulse 80
space 19395
pulse 83
...etc... 

Now that we know our device is working, we can configure it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.38.92