Labs / Electronic modules

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

Author: Li Zisheng · Source: FreakStudio open documentation, v1.4 · License: CC BY 4.0 · Driver code (communication/irtranslation_driver): MIT License

Contents
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

I. Module Introduction

The infrared receiving module based on TSOP34138 takes the TSOP34138 infrared receiver as the core, integrates circuits such as power filtering and status indication, can demodulate 38kHz carrier infrared signals and output digital level (DIN pin); it has an operating voltage range of 2.5–5.5V, a typical receiving distance of up to 45 meters, and supports wide-temperature operation from -25 to 85°C;The module connects to the main control device (such as a microcontroller) through pins including GND, VCC, and DIN. It is suitable for scenarios such as infrared remote control signal reception and short-range infrared data communication, featuring strong anti-interference capability, high sensitivity, and Plug and Play.

II. Introduction to Major Chips

2.1 Chip Overview

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

TSOP34138 is Vishay 's integrated infrared receiver, which incorporates a photodetector and a preamplifier, integrates a 38kHz bandpass filter and anti-EMI design, and can directly demodulate infrared remote control signals and output digital levels via the OUT pin; it operates over a voltage range of 2.5–5.5V with ultra-low power consumption, features strong resistance to ambient light interference, and is suitable for noisy electromagnetic environments; its pin configuration is defined as 1= OUT (signal output), 2= GND (ground), 3= Vs (power supply), and can be directly interfaced with main control devices such as microcontrollers;Widely used in infrared remote control systems such as those for televisions and air conditioners, it can stably receive infrared signals within a maximum distance of 45 meters, serving as a core component for infrared data reception and decoding.

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

Different models of integrated TSOP3x infrared receivers have different demodulatable signal frequencies and pin definitions.

2.2 Pin Definition

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

2.3 Functional Block Diagram

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

This functional block diagram illustrates TSOP34138 the internal signal processing flow of the infrared receiver:

  1. First, PIN diode receives the infrared optical signal and converts it into an electrical signal;
  2. After being initially processed by the input stage (Input), the electrical signal is sent to the Automatic Gain Control (AGC) module. AGC, coordinated by the control circuit (Control circuit), automatically adjusts the gain according to the signal strength to adapt to infrared signals from different distances;
  3. The signal then enters a band-pass filter (Band pass), whose filtering frequency (e. g., the 38kHz carrier commonly used in infrared remote controls) is set by the control circuit to filter out irrelevant frequency interference;
  4. The amplitude-modulated signal after band-pass filtering is sent to the demodulator (Demo - dulator) to demodulate the original digital signal;
  5. Finally, the demodulated signal is output from pin 1 (OUT) via the output stage (including transistors, etc.), completing the conversion from "infrared light to digital electrical signal".

2.4 Performance Parameters

2.4.1 Electrical Parameters

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

2.4.2 Photoelectric Characteristics

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)
GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

2.5 Reference Circuit

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

This reference circuit is a typical application of the interaction between infrared transceiver and microcontroller: the left part consists of TSAL series transmitting tubes to form an infrared transmitting end, which transmits modulated infrared signals; the intermediate infrared receiving module operates via three pins: VS (power supply), OUT (signal output), and GND (ground), which receives the infrared signal and demodulates it into a digital level;The right side passes through R1 and C1 to form an RC filter network (recommended for use when VS < 2.8 V, which is used to reduce power supply ripple) to stably supply power to the receiving head. Besides, the OUT pin of the receiving head is directly connected to the IO port of the microcontroller(μC), and GND shares a common ground with the microcontroller, so that the microcontroller can collect and process infrared signals, realizing a complete link of "transmission → reception → digital processing".

2.6 Chip Configuration

None.

None.

2.8 PCB Routing Precautions

None.

III. Circuit Engineering

3.1 Circuit Source Engineering

To obtain the source project of the circuit, please follow the official account [Freak Embedded]

3.2 Module Usage Instructions

The schematic diagram of this module is shown below:

SCH_TSOP34138-Based Infrared Receiver Module_v1.1_2025-09-18.pdf 1.3 MB

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

This module provides a digital output interface:

3.3 Application Experiment

Here, we use the GraftPort-RP2040 development board for testing, and connect the IR333C-based infrared transmitting module and the TSOP34138-based infrared receiving module to the main controller via the DIO interface for communication.

Here, we first use the HY2.0-4P cable to connect the module to the GraftPort-RP2040 development board's DIO0 and DIO1 interfaces:

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

The module connections are shown in the following table:

Infrared Transmit Module Based on IR333C:

Development Board Pins

Module Pins

Description

Pin 6

DOUT

Infrared signal transmission output pin

Pin 7

NC

-

Infrared receiving module based on TSOP34138:

Development Board Pins

Module Pins

Description

Pin 14

DIN

- Infrared signal receiving input pin

Pin 15

NC

-

Here, before conducting communication, we need to align the infrared transceiving units between the modules as much as possible:

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

Here, we need to search for the relevant driver packages on uPyPI: https://upypi.net/zh/

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

Enter irtranslation_driver to search, and the following will be displayed:

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

Click to copy the local installation command:

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

Here, we can use the mip tool to import module driver library code. The following are the usage commands for the mpremote tool:

mpremote mip install github:FreakStudioCN/GraftSense-Drivers-MicroPython/communication/irtranslation_driver

After importing the IR infrared transceiver driver - MicroPython driver code, copy the following main.py code into our project:

# Python env   : MicroPython v1.23.0
# -*- coding: utf-8 -*-
# @Time    : 2025/8/26 10:11 PM
# @Author  : 缪贵成
# @File    : main.py
# @Description : Test file for the nec_16 protocol on the Raspberry Pi Pico

# ======================================== Import Modules =========================================

import time
from machine import Pin
from ir_tx.nec import NEC
# nec_16 has three parameters in the callback function
from ir_rx.nec import NEC_16

# ======================================== Global Variables ============================================

# ======================================== Functions ============================================

# If using nec_8, pass variable-length arguments; this is nec_16

def ir_callback(addr: int, cmd: int, repeat: bool) -> None:
    """
    NEC protocol receive callback function (3-parameter version).

    Args:
        addr (int): Received address
        cmd (int): Received command code
        repeat (bool): Whether this is a repeat code (True = yes, False = no)

    Notes:
        The callback is called by the NEC receive module and is not ISR-safe.
        Output the received data to the serial port.

    ==========================================

    NEC IR signal receive callback (3-parameter version).

    Args:
        addr (int): Received address
        cmd (int): Received command
        repeat (bool): Repeat flag (True = yes, False = no)
    Notes:
        Called by NEC IR receiver. Not ISR-safe.
        Prints received data to REPL.
    """
    print(f"[RX] Address=0x{addr:04X}, Cmd=0x{cmd:02X}, Repeat={repeat}")

# ======================================== Custom Classes =============================================

# ======================================== Initialization configuration ===========================================

# Power-on delay of 3 s
time.sleep(3)
print("FreakStudio:Infrared transceiver test")

# Transmitter connected to GP6
TX_PIN = Pin(6, Pin.OUT)
# Receiver connected to GP14
RX_PIN = Pin(14, Pin.IN)
# 38kHz transmit
ir_tx = NEC(TX_PIN, freq=38000)
# Receive NEC
ir_rx = NEC_16(RX_PIN, ir_callback)
print("[System] Ready... TX=GP6, RX=GP14")

# ========================================  Main Program  ===========================================
while True:
    print("[TX] Sending NEC signal...")
    # Address=0x10, command=0x20
    ir_tx.transmit(0x10, 0x20)
    time.sleep(2)

Burn the code, open the terminal, and use the mpremote tool to connect to the main controller. The output is as follows:

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)

It can be seen that when the infrared receiving module based on TSOP34138 receives the data sent by the infrared transmitting module based on IR333C, it will trigger the callback function to print[RX]content.

IV. Drivers

irtranslation_driver.zip 27 KB

None.

VI. Revision History

Document Version

Date of Modification

Modifier

Modified Content

v1.0

2025.8.20

Miu Guicheng

Initialize the document

v1.1

2025-09-18

Li Zisheng

Added PCB routing precautions for Version 2.8

Revised Section 3, Instructions for Circuit Source Project and Module Usage, and added a secondary heading:

3.1 Circuit Source Engineering, 3.2 Module Usage Instructions, 3.3 Application Experiments

The BOM sheet has not been finally checked, the driver has not been re-verified, and the 3.3 application experiment

Not yet specified.

v1.2

2025-12-29

Li Zisheng

Added application experiments and production files

v1.3

2025-12-31

Xin Ruili

Create an open version of the document based on the internal document version v1.2.

v1.4

2026-03-29

Xin Ruili

Modified the application experiment section.

VII. Relevant Materials

7.1 Chip Datasheet

TSOP34138 Infrared Receiver Datasheet.pdf 134 KB

7.2 Unique Icons for PCB Silkscreen

GraftSense - TSOP34138-based Infrared Receiver Module (Open Version)