Skip to main content

thorlabs-powermeter-linux

Thorlabs PM16, PM160, PM100 and PM400 optical power meters on Linux, using the kernel's usbtmc driver. No VISA, no vendor DLL. Comes with a command line tool and a desktop app that does what Thorlabs' Optical Power Monitor does on Windows.

the window

Creator

Warwick Brown
School of Electrical and Information Engineering, University of the Witwatersrand, Johannesburg, South Africa
Email: warwickb10@gmail.com
Homepage: https://www.wits.ac.za/oclab

If you use this in published work, please cite the repository (see CITATION.cff) or acknowledge the Wits OC Lab. Pull requests are welcome.

Install

sudo cp udev/60-thorlabs-pm.rules /etc/udev/rules.d/ && sudo udevadm control --reload-rules
sudo usermod -aG plugdev $USER        # log out and in once
pip install thorlabs-powermeter-linux                # or, before the PyPI release: pip install git+https://github.com/WitsOCLab/thorlabs-powermeter-linux
thorlabs-pm list

For the app (GTK 4 comes from the distribution, so the environment must see system packages):

sudo apt install python3-gi gir1.2-gtk-4.0 gir1.2-adw-1
pipx install --system-site-packages thorlabs-powermeter-linux
thorlabs-pm desktop-install            # puts "Power Meter" in the application menu

Tested on Pop!_OS and Ubuntu 22.04 and 24.04. The app needs libadwaita 1.5 (24.04 or newer); the library and command line do not.

From Python

from thorlabs_pm import PowerMeter

with PowerMeter(wavelength_nm=532) as pm:
    r = pm.read(n=10)                 # {'watts', 'std_watts', 'wavelength_nm', 'dbm', 'n'}
    print(r["watts"], "W")
    pm.configure(auto_range=True)
    pm.zero()                         # store the present reading as the dark level
    print(pm.describe())              # identity, sensor head, calibration date, responsivity

PowerMeter(serial="18090634") picks one meter when several are plugged in. SimPowerMeter has the same interface and no hardware, for tests.

From MATLAB

MATLAB R2022a or newer can call the package directly. Point it at a Python that has the package installed, once per session:

pyenv(Version="/usr/bin/python3");            % or the venv you installed into
pm = py.thorlabs_pm.PowerMeter(pyargs('wavelength_nm', 532));
r = pm.read(int32(10));
watts = double(r{'watts'});
pm.close();

matlab/read_power.m is a working script. Tested with R2026a.

Command line

Command Does
thorlabs-pm list meters on the USB bus
thorlabs-pm read -n 10 --wavelength-nm 532 one averaged reading
thorlabs-pm watch live readings until Ctrl-C (--json for logging)
thorlabs-pm set --auto-range on --zero on settings and the dark-level zero
thorlabs-pm info identity, sensor head, calibration date
thorlabs-pm-gui the app (--sim shows it with a simulated meter, no hardware)

Troubleshooting

  • no Thorlabs usbtmc device: check lsusb shows 1313:, that the udev rule is installed and you are in plugdev.
  • Readings stop after the meter sat idle: USB autosuspend. The udev rule turns it off for the meter; reload the rules and replug.
  • A wrong setting gives an error naming the SCPI command: the code checks the meter's error queue after every write.

Disclaimer

Not affiliated with or endorsed by Thorlabs. "Thorlabs" and the product names are trademarks of Thorlabs, Inc., used here only to say which hardware this works with. The software talks to the meter with the SCPI commands in Thorlabs' own manuals over the standard USBTMC class; it contains no Thorlabs code. It is a laboratory tool, not a safety instrument: do not use its readings for laser safety decisions.

License

MIT. Copyright (c) 2026 Wits OC Lab. See LICENSE.

Acknowledgements

Written for the OC Lab optical computing rig, where it replaced the Windows-only Optical Power Monitor.

Release files for thorlabs-powermeter-linux 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thorlabs-powermeter-linux 0.1.0
File Size Uploaded
thorlabs_powermeter_linux-0.1.0.tar.gz 25.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for thorlabs-powermeter-linux 0.1.0
File Interpreter ABI Platform
thorlabs_powermeter_linux-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.3 kB

Release files / thorlabs_powermeter_linux-0.1.0.tar.gz

Download URL thorlabs_powermeter_linux-0.1.0.tar.gz
Size 25.2 kB
Tags Source
SHA-256 checksum
How to use checksums
65b54beac9752527309555e1ff953a8ae89580aae80e3d83cf4d96e2d327a98c
BLAKE2b-256 checksum
How to use checksums
f2b4764adecc4f8cf3b4612a10459d03db6e7135cbcb1cb07134652a347d2687
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release files / thorlabs_powermeter_linux-0.1.0-py3-none-any.whl

Download URL thorlabs_powermeter_linux-0.1.0-py3-none-any.whl
Size 27.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1100b2974d719a8c82c1a589e954d8b9548fc108d6577e7583744b94e7b845f
BLAKE2b-256 checksum
How to use checksums
a264163986f19f3bc9bb638e46d0791cbaa26a63500ac22eb76feb012bb2a991
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page