Sending IR codes on Raspberry PI Buster

This summer rather than do my usual trick of creating an app I decided to get a Raspberry Pi and investigate interacting with the real world. Or, specifically my TV.

The key items relating to this post are:

  • Raspberry PI 4 Model B with Raspbian Buster
  • Infrared receiver module
  • Infrared transmitter module

It appears that Raspbian Buster changed which IR (Infrared) functions are recommended. The ir-keytable can monitor IR signals, and ir-ctl can send them. Many of the tutorials and blog posts on the web use LIRC.

(I don’t intend to go into how to wire up the components as at least that’s widely unchanged over the years)

Read IR codes

This step is well documented on the web as lots of people want to use their Pi as a Kodi box. To send our codes we first need to read them. Install ir-keytable if you do not already have it.

sudo apt-get install ir-keytable -y

You can then run it in test mode to view the protocol and scancodes being sent by your remote. In the following we’re using -s to point to our IR receiver, yours may be different. If you’ve both the receiver and transmitter attached then these may be swapped.

ir-keytable -t -s rc0

Assuming you’re seeing the codes we can note these details and move on.

Send IR codes

Install ir-ctl.

sudo apt-get install ir-ctl

For the next part I’d recommend having a terminal window with ir-keytable running, just as before. You can then use this to determine if the IR codes are being sent correctly.

Note: If the wavelength of your IR transmitter is 940nM you will not be able to see this in your phone camera. The LED may be lighting but you would not see them.

Take one of the codes you captured from your remote, you should have a protocol and a scancode. In the following example, nec is the protocol, 0x402 is the scancode and r1 is the transmitter.

ir-ctl -S nec:0x402 -d r1

Ensure the transmitter and receiver are aligned (my transmitter had a very tight beam) and if you see the sent code being picked up in the ir-keytable terminal then it’s working.

Do you want LIRC on Buster?

The best guide I found is: Use gpio-ir and gpio-ir-tx with LIRC

Filed under: Uncategorised