Building a Raspberry Pi Infrared Transmitter: Capture, Send and Verify Commands
A Raspberry Pi infrared transmitter can automate a familiar remote-control task, such as selecting an input on a display or adjusting a bench demonstration. Sending light is only one part of the job. The timing must describe the right command, the emitter must reach the receiver, and the application must know what a successful transmission does and does not prove.
Build the system around one harmless, observable command first. A controlled test on your own equipment makes it much easier to separate optical, software and application problems.
Choose hardware that includes a transmitter driver
PMD Way's 38 kHz infrared transmit/receive board for Raspberry Pi includes transmit and receive circuitry and two general-purpose buttons. Its connector is the older 2 × 13 format. Verify its alignment on the intended Pi and confirm the actual signal assignments before installing it.
The listing supplies a pinout illustration, but does not establish every software configuration or newer Pi model's support. Check board revision, supply requirements and GPIO allocation against the supplied documentation. Do not substitute the default pins from an unrelated tutorial.
Disconnect power before fitting or removing the board. Keep the emitter driver within its documented operating conditions; a GPIO is not a substitute for a suitably designed LED driver, and increasing current to improve range can damage the transmitter.
Keep carrier and command timing separate
The carrier is the rapid modulation inside an infrared burst. The command is represented by the sequence of bursts and gaps. A nominal 38 kHz receiver responds to a particular carrier region, but that does not mean every 38 kHz remote uses the same command format.
Vishay's receiver circuit description explains carrier filtering, while its remote-control data-format guide covers different coding arrangements. Use those references to distinguish the layers rather than assuming a receiver's frequency label identifies a protocol.
A demodulating receiver generally gives the burst envelope rather than each carrier cycle. A recorded pulse-and-space file therefore does not necessarily measure the original carrier frequency. Retain the carrier information separately when the capture hardware cannot determine it.
Identify the Linux receive and transmit paths
The Linux remote-control subsystem distinguishes raw infrared timings from decoded scancodes. The kernel's LIRC interface documentation describes both forms. A readable timing stream and a decoded button event are different outputs, even if they originate from the same remote.
Use the appropriate drivers and configuration for the board's receive and transmit pins. Raspberry Pi's official overlay reference documents infrared-related overlays and their parameters. Match the documentation to the installed system rather than relying on an old configuration copied without context.
The v4l-utils project includes ir-ctl for raw infrared operations and device options. Consult the installed tool's help and device capability report to identify which device can receive and which can transmit. Do not assume that the first numbered device is always the transmitter.
Create a command record with enough context
Start with a single short press on the original remote. Capture it several times under the same conditions. Keep the remote at a moderate, repeatable distance rather than pressed directly against the receiver, and avoid moving the board between captures.
Record the target equipment model, button label, capture method and software version. If a decoder identifies the protocol and address, preserve those fields alongside the command. If you retain raw timings, keep the full sequence and its units, not just a screenshot of the first few pulses.
| Field | Why it matters |
|---|---|
| Target and button | Associates the signal with a known action. |
| Carrier information | Prevents the burst envelope being mistaken for a complete optical specification. |
| Protocol or raw timing format | Identifies how the stored command should be interpreted. |
| Short-press and hold observations | Distinguishes one action from repetition. |
| Verified target response | Records what actually happened after transmission. |
Do not treat one unusual capture as a clean command merely because it contains numbers. Compare repeated captures and inspect unexplained gaps or extra frames before using the record in automation.
Verify one transmission at a time
Position the Pi's emitter with a clear view of the target's infrared receiver. Send the selected command once using the correct carrier and supported transmit path. Observe the target directly, then repeat from the same starting state.
For example, selecting a known input is easier to verify than issuing a power toggle when the equipment's initial state is uncertain. If the target supports separate commands for a state, those can simplify repeat testing. If it only supports a toggle, maintain an explicit “state unknown” condition rather than assuming every send succeeded.
A successful software return usually means the transmission request completed at that software layer. It does not prove that the remote equipment received the light or performed the action. A receiver on the Pi may observe its own emitter, but that confirms only a local optical event, not the distant device's response.
Avoid creating a receive-and-retransmit loop
If the same Pi listens and sends, define what happens when its receiver hears a transmission. Blindly retransmitting every received packet can create repeated actions or a loop. Keep capture mode, command testing and normal operation as explicit application states.
During transmission, mark the event in your log. Apply a deliberate policy for locally observed echoes and repeat frames. Do not simply discard all reception for an arbitrary long interval, because that can hide a legitimate next command; test the timing policy against the intended interaction.
Test the installed optical path
Repeat the successful command with the final enclosure in place and at the intended distances and angles. Compare daylight and normal room lighting. An emitter that works on the bench may face a wall after installation, while a decorative front panel can reduce the useful optical path.
Change placement before changing electrical drive. Keep a short acceptance record showing the command, starting state, distance, lighting and observed response. When selecting from infrared add-on boards, that complete workflow matters more than a frequency label alone: it connects a stored command to a repeatable, visible result.