Testing the Receivers

In the GitHub repository that you downloaded, there are several sample programs that we will use to test the IR features of the QT Py Hat. They are located in the "arduino_files" folder. 

Do not yet attach the QT Py Hat to your Raspberry Pi Zero W.

Connect the QT Py to your PC using a USB C cable. Get the program arduino_files/dumpFreq and upload it using the Arduino IDE. Open your serial monitor.

Get an infrared remote for your TV, cable DVR, or another consumer electronic device and point it at the receiver chips on the QT Py Hat and press a button. The program will attempt to decode your signal. If successful, it will tell you the protocol number used by IRLib2, the code for that particular button that could be up to 32-bit long, and other information depending on the type of protocol. It might be the number of bits or an additional address field. Here is a sample output after I pressed the "Volume Up", "Volume Down", "Mute", and "Power" buttons on my Samsung TV remote.

Frequency interrupt=2 Pin=2
Receiver interrupt=1 Pin=1
Number of samples:243	  Total interval (us):6380
Avg. interval(us):26.26	 Aprx. Frequency(kHz):38.09 (38)
Decoded NECx(7): Value:E0E0E01F Adrs:0 (32 bits) 
Number of samples:243	  Total interval (us):6367
Avg. interval(us):26.20	 Aprx. Frequency(kHz):38.17 (38)
Decoded NECx(7): Value:E0E0D02F Adrs:0 (32 bits) 
Number of samples:243	  Total interval (us):6372
Avg. interval(us):26.22	 Aprx. Frequency(kHz):38.14 (38)
Decoded NECx(7): Value:E0E0F00F Adrs:0 (32 bits) 
Number of samples:243	  Total interval (us):6359
Avg. interval(us):26.17	 Aprx. Frequency(kHz):38.21 (38)
Decoded NECx(7): Value:E0E040BF Adrs:0 (32 bits)

The first two lines just tell us which pin numbers and interrupt numbers are used for the IR receivers on this device. We can ignore that.

The next two lines tell us information about the frequency detection of the signal for the "Volume Up" button press. The "(38)" at the end of the second line of information tells us that this is a 38 kHz modulated signal which is the most common kind. IR signals range from about 36 kHz up to 56 kHz.

The next line tells us that it successfully decoded the "NECx" protocol which is protocol number 7 in the IRLib2 system. The value that it decoded was the 32-bit hexadecimal value E0E0E01F. This particular protocol does not make use of the address field so it returns zero. And we are told this is a 32-bit protocol.

The remaining pairs of lines are identical except that they returned a different hexadecimal code. The code for "Volume Down" is E0E0D02F, the "Mute" button is E0E0F00F, and finally, the "Power" button is E0E040BF.

If the frequency is somewhere in the 56-58 kHz range then it is likely that the protocol is protocol 5 "Panasonic Old" and it is unlikely that you will be able to successfully decode the data value using the TSOP 38438. Future versions of the software will allow for decoding such protocols. We will have more info later in this tutorial about what to do if your protocol is not recognized.

Once you are convinced that you're getting reasonable readings from the receivers, we can try testing the transmitter.

Upload the program arduino_files/record and open the serial monitor. Now point your infrared remote at the receivers and press a button that you can easily test. We recommend something like the "Mute" button on your TV. The program will record that signal. Then click on the input line on the serial monitor and press enter. The program will re-transmit the code that it recorded. If you continue sending characters from the serial monitor it will continue to resend that same signal that it recorded until you record a different one.

This should confirm that the IR LEDs and driver circuit is working properly.

In the next section, Set up the software on your Raspberry Pi Zero W. In the final section, we will put everything together and begin configuring your IoT remote for your particular devices.

This guide was first published on Apr 17, 2021. It was last updated on Apr 17, 2021.

This page (Testing the QT Py Hat) was last updated on May 08, 2021.

Text editor powered by tinymce.