Labs / Bipes + MicroPython / 8 Actuators (Outputs / Actuators)

8.12 Want to control a device with a remote? Receive infrared remote control signals! โ€”โ€” Infrared receiving module based on TSOP34138

Author: Li Zisheng ยท Source: FreakStudio open documentation ยท License: CC BY 4.0

Contents

Young makers, today let's unlock a "secret walkie-talkie that can send and receive invisible light signals" ๐Ÿ”ฎ!

When you press a button on a TV remote control, it emits an invisible infrared light signal, and the receiving sensor inside the TV will "pick up" the command and execute it. The infrared receiver module based on TSOP34138 paired with the infrared transmitter module we use today acts like an "infrared walkie-talkie" for the development board, enabling it to transmit and receive invisible infrared signals โ€” itโ€™s incredibly cool for building infrared remote controls, obstacle-avoidance cars and more โœจ!

1. Module Introduction

1.1 Infrared Transmitting Module

At its core is an infrared LED that emits infrared light invisible to the human eye. To avoid interference from natural light, it uses a 38kHz high-frequency signal to modulate the infrared light (much like "encrypting" the infrared light), so that the receiving module only recognizes signals of this frequency.

1.2 Infrared Receiving Module (TSOP34138)

This is a receiver module specifically designed to "listen" for 38kHz infrared signals. It automatically demodulates the signals embedded in infrared light, converting the encoded infrared light into electrical signals recognizable by the development board. When a matching infrared signal is received, the output pin will transition from a high level to a low level, triggering an interrupt or detection event.

Features of their coordination:

These blocks are commonly used in graphical programming:

2. Wiring Instructions

8.12 Want to control a device with a remote? Receive infrared remote control signals! โ€”โ€” Infrared receiving module based on TSOP34138

2.1 Infrared Transmit Module Based on IR333C (Connected to DIO2)

Responsible for transmitting infrared signals modulated at 38kHz.

Development Board Pins

Module Pins

Description

Pin 6

DOUT

Infrared signal transmission output pin

Pin 7

NC

-

2.2 Infrared receiving module based on TSOP34138 (connected to DIO0)

Responsible for receiving and demodulating infrared signals.

Development Board Pins

Module Pins

Description

Pin 14

DIN

- Infrared signal receiving input pin

Pin 15

NC

-

๐Ÿ“Œ Note

3. Example: Infrared Signal Transceiver Demonstration

Experiment Objective: Make the infrared transmitting module continuously transmit analog infrared signals of 38kHz; when the receiving module detects the signal via interrupt, print "Infrared Triggered" on the terminal to intuitively experience the effect of "invisible optical communication".

Everyday Life Insight: The communication between a TV remote control and a television works on this exact principle. Now let's build our own "mini infrared remote control and receiver"!

The graphical program is as follows:

8.12 Want to control a device with a remote? Receive infrared remote control signals! โ€”โ€” Infrared receiving module based on TSOP34138

Building Block Assembly Steps:

๐Ÿ”ด Infrared Transmitter Section (Continuous Signal Transmission)

  1. Infinite Loop Firing
    • Drag in the repeat while true block to keep the launch module working continuously;
  2. Simulated 38kHz modulated signal
    • Drag in set output pin block, select Pin 27 / GPIO21, and set it to true;
    • Drag in the delay block and set it to 0.1 second (simulate the high level of a high-frequency pulse);
    • Drag in another set output pin block, select Pin 27 / GPIO21, and set it to false;
    • Drag in the delay block and set it to 0.1 seconds (simulating the low level of a high-frequency pulse);
    • (Note: The actual 38kHz corresponds to a period of 1/38000 โ‰ˆ 26ฮผs; the 0.1 second used here is for simplified demonstration, and a real project requires PWM to output a 38kHz signal)

๐ŸŸข Infrared receiving section (interrupt detection signal)

  1. Configure external interrupts
    • Drag in External event (Interrupt on Input Pin) block;
    • Set the Trigger to IRQ_FALLING (triggered when a high-to-low signal transition is detected);
    • Selected Pin: Pin 9 / GPIO6;
  2. Trigger Feedback
    • When an interrupt is triggered, add the print "Infrared triggered" block.

Experimental Effect:

Graphical blocks will be automatically converted into MicroPython code, and the running results will be displayed:

8.12 Want to control a device with a remote? Receive infrared remote control signals! โ€”โ€” Infrared receiving module based on TSOP34138

Directly importable building blocks:

Infrared transceiver.xml 3 KB

Tips

  1. ๐Ÿ”” Safety Reminder:
    • Do not look directly at the infrared emitter; although infrared light is invisible, high-power emission may cause eye damage.
    • Keep the transmitting and receiving heads clean to prevent dust from blocking the optical path.
  2. ๐Ÿ› ๏ธ Debugging Tips:
    • Weak signal / No reception: Ensure that the transmitter and receiver are aligned, and the distance between them does not exceed 10 meters;
    • Frequent false triggers: Keep away from strong light sources (such as sunlight, table lamps) to avoid interfering with infrared signals;
    • For real projects, it is recommended to use PWM to output a 38kHz signal (for more accurate frequency) instead of simulating it with high and low levels.
  3. ๐ŸŽฎ Advanced Gameplay:
    • Add encoding (e. g. NEC code) to the infrared signal to make an infrared remote control capable of controlling multiple functions;
    • When paired with a servo or LED, it can control the rotation of the servo or the on/off state of the LED via infrared signals.

โœจ Interactive Quick Question

  1. Think about it: Why is 38kHz modulation used for infrared signals? What problems will arise with unmodulated infrared signals?
  2. Try this: Move the transmitter and receiver 5 meters apart and check if the signal can still be received. Then block the optical path with a book and observe whether the signal is interrupted.

Summary

  1. The infrared transceiver module based on TSOP34138 is an invisible optical communication module that enables short-distance wireless signal transmission;
  2. The transmitting module uses 38kHz modulated infrared light, and the receiving module demodulates the signal, delivering strong anti-interference performance;
  3. The basic usage is simple communication of "simulated transmission + interrupt reception", while the advanced usage is to add encoding to implement complex remote control;
  4. It is a core module for infrared remote control, obstacle avoidance, and interactive toys, enabling development boards to have the capability of "wireless control".