Skip to content

IR Receiver Wireling Tutorial

TinyCircuits IR Wireling product photo

This Wireling lets you receive Infrared signals in the 38 kHz range, standard for most TV and appliance remotes. This sensor demodulates the 38 kHz carrier frequency and outputs only the High-Low signals, making it easily integrable with existing Arduino libraries. Well documented and easy to use IR protocols include the Sony, Sharp and NEC protocols, often included in Arduino IR Libraries.

Great for use with the IR Emitter Wireling!

Technical Details Vishay IR Sensor Specs
  • Improved immunity against HF and RF noise
  • Height of 0.8 mm
  • ± 75° half angle sensitivity
  • Low supply current
  • Photo detectors and preamplifier in one package
  • Internal filter for PCM frequency
  • Supply voltage: 2.5 V to 5.5 V
  • Improved immunity against optical noise
  • Insensitive to supply voltage ripple and noise
TinyDuino Power Requirements
  • Voltage: 3.0V - 5.5V 
  • Current: 0.7mA
Pins Used - Optional pin using 0Ω Resistors 
  • A5/SCL -  Pulse Signal
  • A4/SDA - Pulse Signal 
  • A(x)/INT -  Pulse Signal 
Dimensions
  • 10mm x 10mm (.394 inches x .394 inches)
  • Max Height (from lower bottom of TinyBoard to upper top TinyBoard Connector): 3.65mm (0.144 inches)
  • Weight: 1 gram (.04 ounces)

Materials

To interface with any TinyCircuits Arduino board, you will need the Arduino IDE and a Micro USB Cable

There are multiple processor/adapter combinations that can be used with Wirelings. Use the following table to find the combination that works for you.

Processor Adapter
*TinyDuino and USB TinyShield Wireling Adapter TinyShield
*TinyZero Wireling Adapter TinyShield
*TinyScreen+ Wireling Adapter TinyShield
WirelingZero N/A
*RobotZero N/A
Arduino Wireling Arduino Shield
Raspberry Pi Wireling Pi Hat

* These processors have a 32-pin connector and can have multiple Wireling Adapter TinyShields stacked to increase the number of Wireling ports up to a maximum of 32 total Wireling ports.

In order to interface with Wirelings, you'll need the appropriate number of Wireling Cables and the Wireling.h Library (You can download this from GitHub as linked, or from the Library Manager in the Arduino IDE).

You will also need the IR Receiver Wireling and the library included in one download in the table below:

Wireling Code
Port 0 IR Receiver Wireling Library & Example Sketch

Hardware Assembly

Depending on the development system you choose, you will need to put together a TinyDuino stack using the 32-pin tan connectors, or you will just need to plug in your Wireling to Port 3 using a Wireling Cable. (You can change this port in the included Arduino Sketch using the Wireling.selectPort() function)

NOTE: Be mindful when inserting Wireling Cables - the connector pins inside the 5-pin connectors on Wirelings can be bent when cables are inserted at an angle.

TinyCircuits IR Receiver Wireling assembly with WirelingZero


Software Setup

If you have not already done so, download the IR Receiver Library & Example Code. To install an Arduino library, check out our Library Installation Page.

Once downloaded, open the example titled IRReceiverWirelingBasicExample.ino in the Arduino IDE. All the necessary files for the program are included in the zipped folder.

Make the correct Tools selections for your development board. If unsure, you can double check the Help page that mentions the Tools selections needed for any TinyCircuits processor.


Upload Program

This program shows how to use the IR Receiver Wireling to receive NEC IR codes (in this example, the codes used with TinyTV Remote) and print the results to the Serial Monitor. If these codes are recognized, a success message will be printed.

To customize the code for usage with other remotes, point and click the remote at the IR Received and copy down the IR code printed to the Serial Monitor to use. You should get a Serial Monitor message like:

Unrecognized code! 7D2B46EF
Code
/************************************************************************
   IR Receiver Wireling Example
   This code shows how to use the IR Receiver Wireling to receive NEC
   IR codes(in this example, the codes used with TinyTV) and print the
   results to the Serial Monitor.

   Hardware by: TinyCircuits
   Written by: Ben Rose for TinyCircuits

   Initiated: 11/20/2019
   Updated: 05/06/2020
 ************************************************************************/

#include <IRremote.h>
#include <Wire.h>
#include <Wireling.h>

#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#endif

// Define codes as 32 bit unsigned integers
uint32_t powerCode = 0x10AF8877;
uint32_t volUpCode = 0x10AF708F;
uint32_t volDownCode = 0x10AFB04F;
uint32_t chanUpCode = 0x10AF807F;
uint32_t chanDownCode = 0x10AF20DF;
uint32_t muteCode = 0x10AFF00F;

// Receive and transmit can be done on any IO pin. Pick A0-A3 for Wireling ports 0-3.
int RECV_PIN = A3;

IRrecv irrecv(RECV_PIN);

void setup(void) {
  SerialMonitorInterface.begin(9600);
  Wire.begin();
  Wireling.begin();
  while (!SerialMonitorInterface && millis() < 5000); //This will block for 5 seconds or until the Serial Monitor is opened on TinyScreen+/TinyZero platform!

  irrecv.enableIRIn(); // Start receiving data
}

void loop() {
  decode_results results;
  if (irrecv.decode(&results)) {
    irrecv.resume(); // Receive the next value
    if (results.decode_type = NEC && results.bits == 32) { //Check if there's a match for our expected protocol and bitcount
      if (results.value == powerCode) {
        SerialMonitorInterface.println("powerCode received!");
      } else if (results.value == volUpCode) {
        SerialMonitorInterface.println("volUpCode received!");
      } else if (results.value == volDownCode) {
        SerialMonitorInterface.println("volDownCode received!");
      } else if (results.value == chanUpCode) {
        SerialMonitorInterface.println("chanUpCode received!");
      } else if (results.value == chanDownCode) {
        SerialMonitorInterface.println("chanDownCode received!");
      } else if (results.value == muteCode) {
        SerialMonitorInterface.println("muteCode received!");
      } else {
        SerialMonitorInterface.print("Unrecognized code! ");
        SerialMonitorInterface.println(results.value, HEX);
      }
    } else {
      SerialMonitorInterface.print(results.decode_type);
      SerialMonitorInterface.print(" ");
      SerialMonitorInterface.print(results.bits);
      SerialMonitorInterface.print(" ");
      SerialMonitorInterface.println(results.value, HEX);
    }
  }
}

To customize your own remote, use the IR Emitter Wireling in combination with the IR Receiver Wireling!


Downloads


Contact Us

If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

Thanks for making with us!