Introduction
The TDSN7200 from Tokyo Devices is a compact USB sensor that measures temperature, relative humidity, and barometric pressure.
In this guide, we’ll connect the sensor to a Raspberry Pi, install the required tools, configure USB permissions, and retrieve measurements from Python.
1. About the TDSN7200
The TDSN7200 is a USB-connected environmental sensor designed for accurate temperature, humidity, and pressure measurements. Because it connects over USB, it can be used with a Raspberry Pi without any additional interface circuitry.
Its measurement ranges and typical accuracy are:
- Temperature: −40 to 125°C, ±0.2°C accuracy
- Relative humidity: 0 to 100% RH, ±1.8% RH accuracy
- Barometric pressure: 260 to 1,260 hPa, ±0.1 hPa accuracy
2. What You’ll Need
Before getting started, make sure you have:
- A Raspberry Pi running Raspberry Pi OS
- An internet connection over Wi-Fi or Ethernet
- Python 3, which is included with most Raspberry Pi OS installations
- A TDSN7200 sensor
3. Install the Required Packages
Open a terminal on your Raspberry Pi and install the required development tools and libraries:
sudo apt update
sudo apt install -y git build-essential libusb-dev python3 python3-pip
These packages provide the following:
gitdownloads the source code from GitHub.build-essentialprovides the compiler and build tools.libusb-devprovides the library needed to communicate with USB devices.
4. Configure USB Permissions
By default, access to USB devices may be restricted to the root user. To allow regular users to communicate with the sensor, create a udev rule:
sudo tee /etc/udev/rules.d/99-usb-tokyodevices.rules <<'EOF'
SUBSYSTEM=="usb", ATTR{idVendor}=="32ee", ATTR{idProduct}=="177d", MODE="0666"
EOF
Here, 32ee is the TDSN7200 vendor ID and 177d is its product ID.
Reload the udev rules and apply the changes:
sudo udevadm control --reload-rules
sudo udevadm trigger
If the sensor is already connected, unplug it and reconnect it after running these commands.
5. Build the td-usb Command-Line Tool
Tokyo Devices provides the td-usb command-line utility for communicating with its USB devices.
Clone the repository and build the utility:
git clone https://github.com/tokyodevices/td-usb.git
cd td-usb
make
Run the compiled program to confirm that the build succeeded:
./td-usb
If the command displays version or usage information, the build was successful.
Install the executable under /usr/local/bin so that it can be called from anywhere:
sudo install -m 0755 td-usb /usr/local/bin/td-usb
Confirm that it is available in your command path:
td-usb
6. Read Sensor Data from Python
The following Python script reads temperature, humidity, and pressure measurements every 10 seconds:
#!/usr/bin/env python3
import subprocess
import time
def read_sensor():
result = subprocess.run(
["td-usb", "tdsn7200", "get"],
capture_output=True,
text=True,
)
if result.returncode != 0:
print(f"Failed to read the sensor: {result.stderr.strip()}")
return
temperature, humidity, pressure = result.stdout.strip().split(",")
print(
f"Temperature: {temperature} °C, "
f"Humidity: {humidity} % RH, "
f"Pressure: {pressure} hPa"
)
if __name__ == "__main__":
print("Starting sensor measurements. Press Ctrl+C to stop.")
try:
while True:
read_sensor()
time.sleep(10)
except KeyboardInterrupt:
print("\nMeasurement stopped.")
Save the script as read_sensor.py, make it executable, and run it:
chmod +x read_sensor.py
./read_sensor.py
You should see output similar to the following:
Temperature: 24.18 °C, Humidity: 48.72 % RH, Pressure: 1008.31 hPa
Press Ctrl+C to stop collecting measurements.
Conclusion
With the TDSN7200 and a Raspberry Pi, you can start collecting temperature, humidity, and barometric pressure data with only a small amount of setup.
From here, you could extend the Python script to log readings to a CSV file, store them in a database, or display them on a dashboard. The sensor is suitable for experiments, environmental monitoring, research, and other Raspberry Pi projects.

