
IOT IR Remote using Raspberry Pi Zero W and QtPy Hat
Created by Chris Young
Last updated on 2021-04-30 02:30:46 PM EDT

2
3
4
5
5
7
9
9
15
16
16
19
19
19
21
21
23
23
23
26
27
29
31
32
32
32
35
36
38
38
39
Guide Contents
Guide Contents
Overview
Project History
Parts Required
Raspberry Pi Items
QT Py and Accessories
QT Py Hat Board and Components
You can submit the board files to your favorite board manufacturer, make the board yourself or you can also
order the board directly from the following vendors
Other items
QT Py Hat Assembly
Optional Features
QT Py Software
Download the Software
Installing IRLib2
Testing the QT Py Hat
Testing the Receivers
Raspberry Pi Zero W Software and Setup
Setting up the Raspberry Pi
Installing NOOBS
Connecting to Wi-Fi
Initial Configuration
Enabling Samba Server
Installing Files
Installing Flask
Disabling Bluetooth
Testing the Python App
Final Configuration Steps
Programming Custom IR Codes
What If It Does Not Decode?
Final Steps
3D Printed Case
© Adafruit Industries https://learn.adafruit.com/iot-ir-remote-using-raspberry-pi-zero-w-and-qtpy-hat Page 2 of 41

Overview
In this project, we will create an infrared remote control for your TV, cable box, DVR, Blu-ray, or another
similar consumer electronic device. The remote control is operated by a webpage interface. The
Raspberry Pi serves the webpage over your local Wi-Fi network. You can access it on your PC, laptop,
tablet, or phone as long as it is connected to your local Wi-Fi network.
The ability to control your TV or cable/DVR and other devices over a webpage is a very popular idea that
has led to some commercially available products. Such products are often expensive, limited in their
customization capabilities, and often dependent upon cloud-based services that can be a security risk and
may not survive the useful life of the product.
These devices are especially useful as an assistive technology device for a person with a disability such
as me. Someone with limited strength and hand dexterity often cannot use a traditional remote control.
The ability to use a web interface is a handy alternative to a traditional remote because it also allows
leveraging the power of other assistive technology solutions such as eye gaze, speech recognition, and
AT switch control which the user may already have implemented for accessing the internet.
It is based on a Raspberry Pi Zero W and Adafruit QT Py-SAMD21. The QT Py is soldered to a custom
open-source Hat that attaches to the Raspberry Pi Zero W.
The board, called the QT Py Hat, was designed by Bill Binko. The Hat also contains infrared transmit and
receive circuitry. The Raspberry Pi communicates with the QT Py through the UART RX and TX pins via
the hat. There is also the option to connect I C or SPI interfaces of the two boards through the hat via
various jumpers.
Although a Raspberry Pi on its own could do infrared output, it would have to do so via bit-bang because it
cannot do PWM output to the IR LED driver circuit. It would require complicated drivers. It ties up the
processor which could cause an interruption in other activities such as Wi-Fi data coming and going. By
handing off the IR processing to the QT Py, it simplifies the entire process and makes it more reliable.
The combination of Raspberry Pi and QT Py provides for a variety of other potential uses such as adding
analog I/O to the Raspberry Pi. We will only be concentrating on the infrared aspects of this system but
future software updates will make it easier to use the other functions of the QT Py as well as its STEMMA
QT interface.
2
© Adafruit Industries https://learn.adafruit.com/iot-ir-remote-using-raspberry-pi-zero-w-and-qtpy-hat Page 3 of 41

Here is a YouTube video demonstrating how the device works to control my TV and Cable DVR box. Note
it can be reconfigured for most any consumer electronic device such as a Blu-ray player or even an old
VCR that uses an infrared remote.
Project History
Here's a brief personal history of how this project came to be. It's not necessary to know this to build the
project but I thought you might find it interesting.
Several years ago I purchased a commercially available web-based IR remote called a "RedEye Remote"
however its web interface was dependent upon a cloud-based server. When the company went bankrupt,
the device became a useless brick. Then I developed my own solution using an Arduino compatible board
called Pinochio. (That's how they spelled it to avoid potential trademark infringement.) It was an early
system providing IoT capabilities. Unfortunately, it too relied on a cloud service that eventually
disappeared.
My next solution was to use an Arduino Yún which was the first official Arduino product supporting IoT. It
consisted of a small Linux system running WRT and was interfaced with what was essentially an Arduino
Leonardo based on the ATMEGA 32u4. My infrared transmit and receive library IRLib2 already supported
the 32u4 so it was a natural choice although somewhat expensive at approximately $75.
The Yún was eventually discontinued. Fortunately, my solution did not rely on any cloud-based systems
and was based entirely on my local Wi-Fi system so it continues to work to this day. There is now a
revision 2 of the Yún that sells for about $56 which is still a little bit expensive.
I was recently contacted by Ean Price who works with an organization that provides assistive technology
solutions to people in Canada. He had seen a video I did about various assistive technology gadgets I
have built and among them was the Yún-based device. He wanted to build one for himself and perhaps as
many as 5 more people. Long-term he speculated they might create as many as 50 of the devices.
After a brainstorming session with Bill Binko of ATMakers.org (https://adafru.it/RF6), we concluded that the
Yún was expensive old technology and if we were going to be assisting lots of clients with such devices
we could come up with a simpler more cost-effective solution. The result is the QT Py Hat project we
present here.
Although designed to be an IR remote, it also is an extremely cost-effective alternative to the Yún. It does
not yet have the software support of the Yún but we will be working to develop this platform further in the
near future.
© Adafruit Industries https://learn.adafruit.com/iot-ir-remote-using-raspberry-pi-zero-w-and-qtpy-hat Page 4 of 41

Parts Required
Here is a list of everything you will need for this project.
Raspberry Pi Items
Although this project can use any Raspberry Pi that has Wi-Fi capability which includes the various
varieties of models 3 and 4, we recommend the Raspberry Pi Zero W or Raspberry Pi Zero WH. The "WH"
is identical to the "W" model except that it has the headers pre-soldered. If you already have 2 x 20 pin
headers available you can save $4 and solder them yourself.
Raspberry Pi Zero WH (Zero W with Headers)
If you didn't think that the Raspberry Pi Zero W could possibly get any better, then boy do we have a
pleasant surprise for you! The new Raspberry Pi Zero...
$14.00
In Stock
You will need a 5V power supply. We recommend this 2.5 amp supply with a micro USB cable already
attached.
Add to Cart
© Adafruit Industries https://learn.adafruit.com/iot-ir-remote-using-raspberry-pi-zero-w-and-qtpy-hat Page 5 of 41

5V 2.5A Switching Power Supply with 20AWG MicroUSB Cable
Our all-in-one 5V 2.5 Amp + MicroUSB cable power adapter is the perfect choice for powering singleboard computers like Raspberry Pi, BeagleBone or anything else that's power...
$7.50
In Stock
You will need a microSD card for the operating system. It should be at least 8Gb. You will need the
capability of reading and writing information to this card from your PC or laptop. Although you can
purchase an SD card with the NOOBS operating system preinstalled, we have not used that method and
so the procedures we outline here will not exactly be the same. So we recommend getting a plain card
and downloading NOOBS yourself.
Add to Cart
© Adafruit Industries https://learn.adafruit.com/iot-ir-remote-using-raspberry-pi-zero-w-and-qtpy-hat Page 6 of 41

SD/MicroSD Memory Card - 16GB Class 10 - Adapter Included
Add speedy mega-storage in a jiffy using this 16 GB Class 10 micro-SD card. It comes with a SD adapter so
you can use it with any of our shields or adapters! Preformatted to FAT so it...
$19.95
In Stock
We will be configuring the Raspberry Pi Zero W as a "headless" device. That means it will not need a
monitor, keyboard or mouse. If you intend to use the Pi Zero W for other purposes you might want to
consider getting an HDMI cable, Mini-HDMI to HDMI adapter, USB OTG cable, and USB Console cable as
recommended on the Raspberry Pi Zero W product page (https://adafru.it/vMD).
QT Py and Accessories
This project is designed to work with the Adafruit QT Py-SAMD21. In addition to the board itself, you will
also need a USB C cable for programming it.
Note that the QT Py Hat has been designed with the upcoming RP 2040 version of the QT Py board in
mind however, the software included in this tutorial is not compatible with the RP 2040 because it uses
the Arduino IDE C++ as well as IRLib2 neither of which currently support the RP 2040. The IRLib2 library
may eventually support the RP 2040 processor and we will update the software when that capability is
available.
Your browser does not support the video tag.
Adafruit QT Py - SAMD21 Dev Board with STEMMA QT
What a cutie pie! Or is it... a QT Py? This diminutive dev board comes with our favorite lil chip, the SAMD21
(as made famous in our GEMMA M0 and Trinket M0 boards).For...
Out of Stock
Add to Cart
© Adafruit Industries https://learn.adafruit.com/iot-ir-remote-using-raspberry-pi-zero-w-and-qtpy-hat Page 7 of 41

USB Type A to Type C Cable - approx 1 meter / 3 ft long
As technology changes and adapts, so does Adafruit. This USB Type A to Type C cable will help you with
the transition to USB C, even if you're still...
$4.95
In Stock
Although not necessary for this project, you might also want to consider getting the 2 MB SPI 8 pin addon memory chip. The QT Py Hat board has a hole in it to accommodate this chip which might be useful for
future projects.
Out of
Stock
Add to Cart
© Adafruit Industries https://learn.adafruit.com/iot-ir-remote-using-raspberry-pi-zero-w-and-qtpy-hat Page 8 of 41

GD25Q16 - 2MB SPI Flash in 8-Pin SOIC package
These little chips are like miniature SSD drives for your electronics. When you don't need something with
as much storage as a micro SD card, but an EEPROM is too small, SPI (or...
$1.25
In Stock
QT Py Hat Board and Components
The QT Py circuit board is an open-source board. The Eagle CAD files for the board are available in a
GitHub repository that you can download at the button below. The same repository also contains all of the
software necessary for the project as well as STL files for a 3D printed case. You should download it now
for later use.
https://adafru.it/RF7
You can submit the board files to your favorite board manufacturer,
make the board yourself or you can also order the board directly from
the following vendors
QT Py Hat at PCBWay.com (https://adafru.it/RF8)
QT Py Hat at OSHPark.com (https://adafru.it/RF9)
Here are images of the board and schematics.
Add to Cart
https://adafru.it/RF7
© Adafruit Industries https://learn.adafruit.com/iot-ir-remote-using-raspberry-pi-zero-w-and-qtpy-hat Page 9 of 41

You will also need a number of through-hole components. Most of the parts you will need are available
from Adafruit. Some that are not available at Adafruit are available from a variety of suppliers. At the end
of this list will give you a complete list of through-hole parts available from Digi-Key.
First, we will need 2 IR LEDs. We prefer to use a combination of wide-angle and narrow-angle LEDs. This
narrow 20° angle LED is available from Adafruit. A 40° wide-angle LED is available from Digi-Key. See the
Digi-Key parts list at the end.
© Adafruit Industries https://learn.adafruit.com/iot-ir-remote-using-raspberry-pi-zero-w-and-qtpy-hat Page 10 of 41

Super-bright 5mm IR LED
Infrared LEDs are used for remote controls (they're the little LED in the part you point at your TV) and
'night-vision' cameras, and these little blue guys are high powered...
$0.75
In Stock
You will also need an NPN transistor and 2 PNP transistors. Here Adafruit has a combo pack of five of
each or you can buy them separately in packs of 10.
Add to Cart
© Adafruit Industries https://learn.adafruit.com/iot-ir-remote-using-raspberry-pi-zero-w-and-qtpy-hat Page 11 of 41

Bipolar Transistor Kit - 5 x PN2222 NPN and 5 x PN2907 PNP
Transistors are powerful little electronic switches, and we really like these NPN and PNP transistors
whenever we need to control medium-power electronics, such as small motors,...
$1.95
In Stock
You will need a 1K ohm resistor and optionally you may need two 33 ohm resistors. Adafruit carries the 1K
variety but if you need the 33 ohm see the Digi-Key parts list at the end of the page. We will explain later
why you may or may not need the 33 ohm resistors.
Add to Cart
© Adafruit Industries https://learn.adafruit.com/iot-ir-remote-using-raspberry-pi-zero-w-and-qtpy-hat Page 12 of 41

Through-Hole Resistors - 1.0K ohm 5% 1/4W - Pack of 25
ΩMG! You're not going to be able to resist these handy resistor packs! Well, axially, they do all of the
resisting for you!This is a 25 Pack of...
$0.75
In Stock
You will need an infrared receiver such as this TSOP38238 from Adafruit. In the Digi-Key parts list, we
specify a TSOP38438 which has a slightly better automatic gain control circuit however the 38238 from
Adafruit will work fine under most every circumstance. You may also need an infrared learner device the
TSMP 58000 from Digi-Key. We will explain later why you might need a TSMP58000.
Add to Cart
© Adafruit Industries https://learn.adafruit.com/iot-ir-remote-using-raspberry-pi-zero-w-and-qtpy-hat Page 13 of 41