Tips August 14, 2026

Reading a K-Type Thermocouple with a Raspberry Pi

The TDSN7400 from Tokyo Devices is a USB temperature sensor that makes it easy to read a K-type thermocouple from a Raspberry Pi.

This guide walks you through the entire setup, from installing the required tools to reading temperature data in Python.

1. About the TDSN7400

The TDSN7400 is a USB interface designed for K-type thermocouples. Connect a compatible probe, plug the sensor into your Raspberry Pi, and you can read the temperature from the command line.

Key specifications include:

  • Thermocouple type: K-type
  • Measurement range: −40°C to 1,200°C
  • Minimum sampling interval: 100 ms
  • USB connector: USB Mini-B

The measurement range above applies to the sensor itself. The actual usable range also depends on the temperature rating of the connected thermocouple probe.

2. What You’ll Need

Item Description
Raspberry Pi A Raspberry Pi with Raspberry Pi OS installed
TDSN7400 thermocouple sensor Connects to the Raspberry Pi using the included USB cable
TDAC-THC1 K-type thermocouple probe A K-type probe compatible with the TDSN7400
Internet connection Required to install packages and download the source code
Python 3 Included with most Raspberry Pi OS installations

3. Install the Required Tools

First, update your Raspberry Pi and install the packages required to build and run the command-line tool:

sudo apt update && sudo apt upgrade -y
sudo apt install -y git build-essential libusb-dev python3

These packages provide the following:

  • git downloads the source code from GitHub.
  • build-essential provides the compiler and other build tools.
  • libusb-dev provides the library needed to communicate with USB devices.

4. Configure USB Permissions

By default, a regular user may not have permission to access the TDSN7400. Create a udev rule to allow access without running the tool as root.

Run the following command:

sudo tee /etc/udev/rules.d/99-usb-tokyodevices.rules <<EOF
SUBSYSTEM=="usb", ATTR{idVendor}=="32ee", ATTR{idProduct}=="1780", MODE="0666"
EOF

Here, 32ee and 1780 are the USB vendor and product IDs of the TDSN7400.

Reload the rules and apply the changes:

sudo udevadm control --reload-rules
sudo udevadm trigger

Once the rules have been updated, disconnect and reconnect the TDSN7400.

5. Build the TD-USB Command-Line Tool

The TDSN7400 is controlled using TD-USB, the official command-line utility from Tokyo Devices.

Clone the repository and build the tool:

git clone https://github.com/tokyodevices/td-usb.git
cd td-usb
make

Run the executable to confirm that the build succeeded:

./td-usb

If the tool displays its version information, it is ready to use.

Now read a single temperature measurement from the TDSN7400:

./td-usb tdsn7400 get

Example output:

24.875000

The value is the measured temperature in degrees Celsius.

6. Read the Temperature from Python

Next, let’s write a Python script that reads and displays the temperature every 10 seconds.

Inside the td-usb directory, create a file named read_tdsn7400.py with the following contents:

#!/usr/bin/env python3

import subprocess
import time

CMD = ["./td-usb", "tdsn7400", "get"]


def read_temperature():
    result = subprocess.run(
        CMD,
        capture_output=True,
        text=True,
    )

    if result.returncode != 0:
        print("An error occurred:", result.stderr.strip())
        return

    output = result.stdout.strip()

    try:
        temperature = float(output)
    except ValueError:
        print("Could not parse the temperature:", output)
        return

    print(f"Temperature: {temperature:.2f} °C")


if __name__ == "__main__":
    print("Starting TDSN7400 measurements. Press Ctrl+C to stop.")

    try:
        while True:
            read_temperature()
            time.sleep(10)
    except KeyboardInterrupt:
        print("\nMeasurement stopped.")

The script runs the TD-USB command, converts its output to a floating-point value, and formats the result to two decimal places.

7. Run the Script

From inside the td-usb directory, run:

python3 read_tdsn7400.py

The current temperature will be displayed every 10 seconds:

Starting TDSN7400 measurements. Press Ctrl+C to stop.
Temperature: 24.88 °C
Temperature: 24.94 °C
Temperature: 25.06 °C

Press Ctrl+C to stop the script.

8. Conclusion

In this guide, we connected a K-type thermocouple to a Raspberry Pi using the TDSN7400 and read its measurements from both the command line and Python.

Once temperature readings are available from the command line, you can easily incorporate them into data-logging applications, experiments, equipment monitoring systems, and other Raspberry Pi projects.

When measuring high temperatures, always check the maximum temperature rating of the thermocouple probe—not just the measurement range of the TDSN7400—before use.

Related Products

Share This Article

Recent Tips