It's easy to use the High Power Infrared LED Emitter with Python or CircuitPython, and the Adafruit_CircuitPython_IRRemote module. This module allows you to easily write Python code that allows you to send IR remote pulses using the pulseio core module. You can use this breakout with any CircuitPython microcontroller board or with a computer that has GPIO and Python thanks to Adafruit_Blinka, our CircuitPython-for-Python compatibility library.
CircuitPython Microcontroller Wiring
First, wire up an infrared LED emitter to your board exactly as shown below. Here's an example of wiring a Feather M4 to the infrared LED emitter using one of the handy STEMMA JST PH cables:
- Board 3V to LED emitter V+ (red wire)
- Board GND to LED emitter GND (black wire)
- Board pin 5 to LED emitter In (white wire)
You can also use standard 0.100" pitch headers to wire it up on a breadboard:
- Board 3V to LED emitter V+ (red wire)
- Board GND to LED emitter GND (black wire)
- Board pin 5 to LED emitter In (white wire)
Python Computer Wiring
Since there's dozens of Linux computers/boards you can use, below shows wiring for Raspberry Pi. For other platforms, please visit the guide for CircuitPython on Linux to see whether your platform is supported.
Here's the Raspberry Pi wired to the infrared LED emitter and a STEMMA JST PH cable:
- Pi 3V to LED emitter V+ (red wire)
- Pi GND to LED emitter GND (black wire)
- Pi GPIO #5 to LED emitter In (white wire)
Finally here is an example of how to wire up a Raspberry Pi to the infrared LED emitter using a solderless breadboard:
- Pi 3V to LED emitter V+ (red wire)
- Pi GND to LED emitter GND (black wire)
- Pi GPIO #5 to LED emitter In (white wire)
Python Installation of IRRemote Library
You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready!
Once that's done, from your command line run the following command:
sudo pip3 install adafruit-circuitpython-irremote
If your default Python is version 3, you may need to run pip
instead. Make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!
CircuitPython Usage
To use with CircuitPython, you need to first install the IRRemote library, and its dependencies, into the lib folder on your CIRCUITPY drive. Then you need to update code.py with the example script.
Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, and copy the entire lib folder and the code.py file to your CIRCUITPY drive.
Your CIRCUITPY/lib folder should contain the following folders and file:
- adafruit_irremote.mpy

Python Usage
Once you have the library pip3
installed on your computer, copy or download the following example to your computer, and run the following, replacing code.py with whatever you named the file:
python3 code.py
# SPDX-FileCopyrightText: 2022 Liz Clark for Adafruit Industries # SPDX-License-Identifier: MIT # Based on irremote_transmit.py for CPX by ladyada import time import pulseio import board import adafruit_irremote # Create a 'PulseOut' to send infrared signals on the IR transmitter @ 38KHz pulseout = pulseio.PulseOut(board.D5, frequency=38000, duty_cycle=2**15) # Create an encoder that will take numbers and turn them into NEC IR pulses emitter = adafruit_irremote.GenericTransmit( header=[9500, 4500], one=[550, 550], zero=[550, 1700], trail=0 ) # count variable count = 0 while True: # send IR pulse emitter.transmit(pulseout, [255, 2, 255, 0]) # increase count count += 1 # print to REPL print("IR signal sent %d times!" % count) # two second delay time.sleep(2)
If running CircuitPython: Once everything is saved to the CIRCUITPY drive, connect to the serial console to see the data printed out!
If running Python: The console output will appear wherever you are running Python.
The code begins by creating a pulseio
object on pin D5
. This will send infrared signals via the IR transmitter at 38KHz. Then, emitter
is created with the adafruit_irremote
library that will take numbers and turn them into NEC IR pulses.
In the loop, an IR signal is pulsed out every two seconds. In the REPL, you'll see "IR signal sent # times!
" print out after the pulse is sent. The variable count
counts the number of times this occurs and is passed to the string in the REPL.