Before getting started, let's review what you'll need.
- Raspberry Pi 3 (Recommended) or Pi 2 Model B (Supported).
- MATRIX Creator - The Raspberry Pi will be utilizing the IR receiver and emitter from this board. Buy MATRIX Creator.
- Micro-USB power adapter for Raspberry Pi.
- Micro SD Card (Minimum 8 GB) - An operating system is required to get started. You can download Raspbian Stretch and use the guides for Mac OS,Linux and Windows in the Raspberry Pi website.
- A USB Keyboard & Mouse, and an external HDMI Monitor - we also recommend having a USB keyboard and mouse as well as an HDMI monitor handy. You can also use the Raspberry Pi remotely, see this guide from Google.
- Internet connection (Ethernet or WiFi)
- (Optional) WiFi Wireless Adapter for Pi 2. Note: Pi 3 has built-in WiFi.
Using the pigpio library, this guide will walk you through how to record and playback a button from an IR remote.
If you haven't already, be sure to setup your Raspberry Pi with your MATRIX Creator.
This guide will be utilizing pins 13 & 16 of the Raspberry Pi. These pins are connected to the MATRIX Creator's IR transmitters & IR receiver, respectivly. For reference, below is an image of how the Raspberry Pi's GPIOs are connected to the MATRIX Creator.
Keep in mind, that installing any of the MATRIX Programming Environments will also include these MATRIX Dependencies.
Run the following commands in your Raspberry Pi's terminal to add the MATRIX repository & key and update your repository packages.
curl https://apt.matrix.one/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.matrix.one/raspbian $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/matrixlabs.list
Update your repositories and packages.
sudo apt-get update
sudo apt-get upgrade
Install the matrix creator init package.
sudo apt-get install matrixio-creator-init
Reboot your Raspberry Pi.
sudo reboot
2. Installing pigpioOnce your Raspberry Pi has finished rebooting, go back into the terminal and run the following command to install pigpio.
sudo apt-get install pigpio
The Python dependency is also required.
pip install pigpio
3. Download the IR Test RepositoryTo make this process easier, we'll be using the the matrix-creator-ir-test repository. The example in this repository is taken from the IR Record and Playback pigpio example.
Use the command below to instal git.
sudo apt-get install git
With git installed, you can now clone the IR test repository to you home directory.
cd ~/
git clone https://github.com/matrix-io/matrix-creator-ir-test
cd matrix-creator-ir-test
4. Running the CodeBefore recording and playing your command, you'll need to start the pigpio process.
This must be done each time your RaspberryPi boots.
sudo pigpiod
You can then use the commands below to record and playback an IR signal. A TV remote is a great way to test this.
- Record: This command allows you to specify the names of each IR signal you want to record. The command below will ask for 2 IR signals to signify the
channel_up
&channel_down
buttons and store them in a local file namedcodes.json
. You can change the name of the buttons being recorded to match your needs.
python ir_remote.py -r -g16 -f codes.json channel_up channel_down
- Playback: This command allows you to play any IR signal recorded with the previously mentioned command. The command below will play the IR signal that was stored as
channel_up
incodes.json
python ir_remote.py -p -g13 -f codes.json channel_up
Comments