How to Use PyMeasure for Automated Instrument Control and Lab Experiments
Modern labs demand automation, precision, and speed—whether you're running I-V sweeps, temperature profiles, or optical characterizations. PyMeasure is an open-source Python package designed to automate these tasks by controlling lab instruments with clean, readable code.
In this post, we’ll walk through the basics of installing and using PyMeasure to run your first automated experiment.
🧪 What is PyMeasure?
PyMeasure is a Python package that simplifies instrument control and experimental automation. It wraps SCPI/GPIB/USB/serial commands in intuitive Python classes and provides tools for:
- Creating repeatable measurement procedures
- Logging and saving results
- Live data plotting
- GUI support for interactive control panels
⚙️ Step 1: Installation
You can install PyMeasure using either pip or conda:
# Recommended via conda
conda install -c conda-forge pymeasure
# Or via pip
pip install pymeasure
Ensure you also have VISA installed if you're using USB/GPIB interfaces. We recommend using NI-VISA or pyvisa-py backend.
🔌 Step 2: Connect to Your Instrument
PyMeasure comes with drivers for many common lab instruments. Here's a simple example using a Keithley 2400 source meter:
from pymeasure.instruments.keithley import Keithley2400
smu = Keithley2400("GPIB::24") # or "USB0::0x05E6::0x2400::XYZ::INSTR"
smu.apply_current(0.001, compliance_voltage=10)
print(f"Measured voltage: {smu.voltage} V")
You can now control the device just like any Python object—setting values and reading measurements.
📈 Step 3: Run an Automated Measurement Script
Let’s run a simple I-V sweep using the same Keithley:
import numpy as np
currents = np.linspace(-1e-3, 1e-3, 50)
voltages = []
for i in currents:
smu.source_current = i
voltages.append(smu.voltage)
print(f"I: {i:.6f} A, V: {voltages[-1]:.6f} V")
You can save the data to CSV for further analysis.
🧪 Step 4: Use Procedure for Full Experiments
Create a repeatable, configurable experiment using the Procedure class:
from pymeasure.experiment import Procedure, IntegerParameter, FloatParameter
from pymeasure.experiment.results import Results
from pymeasure.experiment.workers import Worker
class IVSweepProcedure(Procedure):
start = FloatParameter("Start Current", units="A", default=-1e-3)
stop = FloatParameter("Stop Current", units="A", default=1e-3)
steps = IntegerParameter("Steps", default=50)
def startup(self):
self.instrument = Keithley2400("GPIB::24")
def execute(self):
for i in np.linspace(self.start, self.stop, self.steps):
self.instrument.source_current = i
voltage = self.instrument.voltage
self.emit('results', {'current': i, 'voltage': voltage})
This procedure can now be run in CLI or GUI mode.
🖥️ Step 5: Add a GUI (Optional)
PyMeasure includes a GUI framework:
from pymeasure.display.windows import ManagedWindow
class IVApp(ManagedWindow):
def __init__(self):
super().__init__(
procedure_class=IVSweepProcedure,
inputs=["start", "stop", "steps"],
displays=["current", "voltage"],
x_axis="current", y_axis="voltage"
)
self.setWindowTitle("I-V Measurement")
if __name__ == "__main__":
app = IVApp()
app.show()
🔌 Supported Instruments
PyMeasure supports instruments from:
- Keithley
- Tektronix
- Keysight
- Thorlabs
- NI and more…
You can also create your own instrument class by inheriting from Instrument.
🧰 Use Cases
- Semiconductor I-V curve tracing
- Thermoelectric cooling tests
- Fiber optic testing
- Photovoltaic cell characterization
- Automated reliability tests
✅ Conclusion
PyMeasure makes it easy to automate your lab, save time, and ensure reproducibility. Whether you're in research or production QA, PyMeasure can scale from simple tests to full GUIs.
Get in Touch with us
Related Posts
- NVIDIA、Microsoft、OpenAI、Google、Oracle 以及 AMD:正在共同推动 AI 泡沫如何形成?
- The Real AI Bubble: How NVIDIA, Microsoft, OpenAI, Google, Oracle — and Now AMD — Shape the Future of Compute
- 深度学习在房地产开发中的应用
- Deep Learning in Property Development
- 代码修复与遗留系统维护服务 —— Simplico 助力企业保持系统稳定、安全、高效
- Code Fixing & Legacy System Maintenance — Keep Your Business Running Smoothly with Simplico
- Python 深度学习在工厂自动化中的应用:2025 全面指南
- Python Deep Learning in Factory Automation: A Complete Guide (2025)
- 工厂 / 制造业专用 Python 开发与培训服务
- Python Development & Industrial Automation Training Services
- 为什么 Python + Django 是现代电商系统的最佳技术栈(完整指南 + 定价方案)
- Why Python + Django Is the Best Tech Stack for Building Modern eCommerce Platforms (Complete Guide + Pricing Plans)
- 三十六计现代商业版:理解中国企业竞争、谈判与战略思维的终极指南
- The 36 Chinese Business Stratagems: A Modern Guide to Understanding How Chinese Companies Compete and Win
- 理解机器学习中的 Training、Validation、Testing
- Understanding Training, Validation, and Testing in Machine Learning
- 深入理解神经网络
- Understanding Neural Networks Deeply
- AI 商品真伪鉴定系统:为现代零售品牌打造的智能解决方案
- AI-Powered Product Authenticity Verification for Modern Retail Brands













