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
- How Agentic AI and MCP Servers Work Together: The Next Step in Intelligent Automation
- DevOps in Django E-Commerce System with DRF and Docker
- How AI Can Solve Real Challenges in Agile Development
- Connecting TAK and Wazuh for Real-Time Threat Awareness
- Scaling Wazuh for Multi-Site Network Security Monitoring
- Why ERP Projects Fail — and How to Avoid It
- How to Build Strong Communities with Technology
- How AI Can Make Open Zoos More Fun, Smart, and Educational
- How to Choose the Right Recycling Factory for Industrial Scrap
- Understanding Modern Database Technologies — and How to Choose the Right One
- The Future Is at the Edge — Understanding Edge & Distributed Computing in 2025
- NVIDIA and the Two Waves: From Crypto to AI — The Art of Riding a Bubble
- From Manual Checks to AI-Powered Avionics Maintenance
- Automated Certificate Generator from XLSX Templates
- Introducing SimpliPOS (COFF POS) — A Café-Focused POS System
- Building a Local-First Web App with Alpine.js — Fast, Private, and Serverless
- Carbon Footprint Calculator (Recycling) — Measuring CO₂ Savings in Recycling Operations
- Recycle Factory Tools: A Smarter Way to Track Scrap Operations
- Running Form Coach — Cadence Metronome, Tapper, Drills, Posture Checklist
- How to Build a Carbon Credit Calculator for Your Business













