infrared transmitter/Driving it/07. A carrier the TK15 hears
Driving it · 07 of 9

A carrier the TK15 hears

A TK15 IR Receiver cannot see a steady beam at all: it is tuned to light flashing 38,000 times a second, and throws everything else away. IRremote makes that carrier on the TK63's pin, in software on an Uno and with a hardware PWM channel on an ESP32 or Pico, and this sketch sends a code to a TK15 on the same board and prints whether it arrived.

A tuned receiver

The TK15's chip is not a light sensor. It is tuned to 38 kHz: it passes light that flashes 38,000 times a second and throws away anything steady or slow, which is how it ignores lamps, windows and the sun. The blink sketch never reaches it. Leave the TK63 on and the TK15 sees nothing.

What the TK15 hears
TSOP18138 · 38 kHz
The sketch makes
Flashing at
38 kHz
TK15 sensitivity
100 %
TK15's red LED
flickers
Bursts at 38 kHz are what the TK15 is tuned to. Its chip pulls SIGNAL LOW for as long as each burst lasts, and its red LED flickers with no sketch on it at all. A remote-control protocol is nothing more than the lengths of these bursts and gaps, and a library times them for you.

Pick what the TK63 sends. Steady light gets nothing through. Bursts of 38 kHz do, and the TK15 pulls its SIGNAL LOW for as long as each burst lasts; its own red LED, which sits on that line, flickers with no sketch on it at all. A remote-control code is only a pattern of such bursts and gaps.

Let the library make it

Nothing on this board makes a carrier: it is a transistor that follows your pin. The carrier is software, and IRremote writes it. On an Uno it switches the pin in a timed loop, 30 % on in each cycle, which is why Serial.flush() comes first: an interrupt mid-frame would put a gap in the tone. On an ESP32, ESP32-S3 or Pico it hands the 38 kHz to a hardware PWM channel. On all four, any output pin works.

The TK63 is the TK16's circuit with a different LED, so everything the IR handbook says about sending, be the remote included, applies to it unchanged.

Two blocks, one board

Wire both blocks to one board: the TK63 as in the first blink, the TK15 as the IR handbook wires it, SIGNAL to D2 on an Uno, GPIO 23 on an ESP32, GPIO 9 on an ESP32-S3, GP16 on a Pico, and VCC to your board's logic voltage, because the TK15's SIGNAL is its chip's output. Stand them face to face, the TK63's lens pointing at the TK15's window, about 30 cm apart. Closer than about 20 cm the TK15 is swamped and decodes nothing.

What you should see

Sending a NEC frame once a second.
sent 0  heard it
sent 1  heard it
sent 2  heard it

The TK63's red LED flickers once a second with each frame, and so does the TK15's. Put your hand between them and the line changes to nothing heard.

The code

Sends a NEC frame once a second with IRremote, the command counting up, and listens for it on a TK15 wired to the same board. Each line says what was sent and whether the TK15 decoded it. Change IR_PIN and RX_PIN to your two pins.

ir_to_tk15.ino
/*
  Infrared Transmitter - to a TK15            TK63 + TK15 / /p/tk63

  Wiring. Count from the square pad on each TinkerBlock board, parts
  up, header at the bottom:

    TK63 transmitter
      GND    -> GND
      VCC    -> 5V, or VBUS on a Pico (only feeds the LEDs)
      NC     -> nothing   (unconnected on the board)
      SIGNAL -> D3, GPIO 22, GPIO 6 or GP17

    TK15 receiver
      GND    -> GND
      VCC    -> 5V on an Uno; 3V3 on an ESP32, ESP32-S3 or Pico
      NC     -> nothing   (unconnected on the board)
      SIGNAL -> D2, GPIO 23, GPIO 9 or GP16

  Uno, ESP32, ESP32-S3, Pico, in that order. Stand the two blocks
  face to face, about 30 cm apart.

  Arduino IDE
    Tools > Board                 your board, e.g. ESP32S3 Dev Module
    Tools > Port                  the one that appears when you plug in
    Tools > USB CDC On Boot       Enabled   (ESP32-S3 only)
    Tools > Manage Libraries      IRremote by shirriff, z3t0 and
                                  ArminJo, version 4 or later
    Serial Monitor                115200
*/

#include <IRremote.hpp>

// The pin the TK63's SIGNAL is wired to.
// Uno: 3. ESP32: 22. ESP32-S3: 6. Pico: 17.
const int IR_PIN = 6;
// The pin the TK15's SIGNAL is wired to.
// Uno: 2. ESP32: 23. ESP32-S3: 9. Pico: 16.
const int RX_PIN = 9;

// Any address nothing else in the room is likely to send. The
// command counts up, so each line shows a new frame arriving.
const uint16_t ADDRESS = 0x12;
uint8_t command = 0;

void setup() {
  // LOW first: nothing on the board holds the transistor off.
  pinMode(IR_PIN, OUTPUT);
  digitalWrite(IR_PIN, LOW);
  Serial.begin(115200);
  // IRremote makes the 38 kHz itself: on an Uno in software, on
  // an ESP32, ESP32-S3 or Pico with a hardware PWM channel.
  IrSender.begin(IR_PIN);
  IrReceiver.begin(RX_PIN, DISABLE_LED_FEEDBACK);
  Serial.println("Sending a NEC frame once a second.");
}

void loop() {
  Serial.print("sent ");
  Serial.print(command);
  Serial.flush();                  // no interrupt mid-frame on an Uno
  IrSender.sendNEC(ADDRESS, command, 0);   // about 68 ms

  // Listen again, and wait long enough to see the frame has ended.
  IrReceiver.restartAfterSend();
  delay(RECORD_GAP_MICROS / 1000 + 5);

  if (IrReceiver.decode()) {
    IRData &d = IrReceiver.decodedIRData;
    if (d.address == ADDRESS && d.command == command) {
      Serial.println("  heard it");
    } else if (d.protocol == UNKNOWN) {
      Serial.println("  heard something, decoded nothing");
    } else {
      Serial.println("  heard another frame");
    }
    IrReceiver.resume();
  } else {
    Serial.println("  nothing heard");
  }

  command++;
  delay(1000);
}

sendNEC does not return until the frame is out, about 68 ms. The address 0x12 is arbitrary; nothing here is a real device's code. The sketch compiles for an ESP32-S3 and an Uno.

View on GitHub · blocks/tk63-ir-transmitter/arduino/ir_to_tk15/ir_to_tk15.ino @ v1.5

When it does not work

Every line says nothing heard.

Watch the TK63's red LED: it flickers with each frame. If it does, the frames are leaving, and the problem is aim or distance. Stand the two blocks face to face, the LED pointing at the TK15's window, about 30 cm apart. If the red LED stays dark, check the TK63's wiring and IR_PIN.

It says heard something, decoded nothing.

Usually the blocks are too close. Within about 20 cm the TK15 is swamped and every burst it measures comes out long. Move them to 30 cm, or turn them to bounce the light off a pale wall.

My old sketch toggled the pin every 13 µs. Why did the TK15 ignore it?

On an Uno digitalWrite itself takes a few microseconds, which a loop of delayMicroseconds(13) does not count, so the tone comes out well under 38 kHz. The TK15 is tuned narrowly and hears little of it. And bursts need the right lengths and gaps to decode as a code. Let the library do both.

Can it control my television?

If your television speaks a protocol IRremote sends, yes, exactly as the TK16 does. Capture your own remote's code with the TK15 first; the address and command here are placeholders.

Where this goes next

A steady beam, a TK64, and the room's own infrared subtracted out.

A beam you can break →

Edit this page — content/books/ir-transmitter/a-carrier-the-tk15-hears.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Infrared Transmitter

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum →