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 ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.