A Python wrapper for Metrohm Autolab potentiostat control via the
EcoChemie.Autolab.Sdk.NET assembly.Author: Shuay Liu
pymetrohmautolab provides a high-level, class-based API for controlling Metrohm Autolab instruments from Python. It wraps the official EcoChemie.Autolab.Sdk .NET assembly via pythonnet (clr), exposing:
- Direct instrument control —
setPotential,setCellOn,setMode,setCurrentRangeviaautolab.Ei - Procedure execution — load
.noxfiles, run measurements, save results - Data loading — extract CV / EIS data from saved
.noxfiles into numpy arrays - Generic command/parameter access — control any NOVA procedure, any parameter, any type
- Data acquisition — read measured potential, current, time directly from procedures
Key design goals:
- Zero-configuration — sensible defaults for SDK paths on Windows
- Backward-compatible — all v0.0.4 methods preserved
- Extensible — generic
getCommand/setParameter*/getOutput*API for any NOVA procedure - Data-friendly — built-in numpy array extraction from saved measurements
| Requirement | Version | Notes |
|---|---|---|
| Windows | 7/8/10 | .NET Framework required |
| Python | 2.7 or 3.6+ | pythonnet works on both |
| Metrohm Autolab SDK | 1.10+ | Must be installed separately |
Install dependencies:
pip install pythonnet numpyInstall this package:
pip install pymetrohmautolabOr from source:
git clone https://github.com/shuayliu/pymetrohmautolab.git
cd pymetrohmautolab
pip install .from pymetrohmautolab import AUTOLAB
# 1. Initialise (uses default SDK paths; override if needed)
ec = AUTOLAB()
# 2. Connect to instrument (PGSTAT204 example)
hdw = R"C:\Program Files\Metrohm Autolab\autolabsdk\Hardware Setup Files\PGSTAT204\HardwareSetup.xml"
if ec.connectToAutolab(hdw):
print("Connected!")
# 3. Direct instrument control
ec.setPotential(0.5) # Set potential (V)
ec.setCellOn(True) # Turn cell on
# 4. Load and measure a procedure
ec.measure(R"C:\data\Cyclic voltammetry.nox")
# 5. Read measured data back
potential = ec.getMeasuredPotential() # list of floats
current = ec.getMeasuredCurrent() # list of floats
time = ec.getMeasuredTime() # list of floats
# 6. Save result with timestamp
ec.saveAs(R"C:\data\result.nox")
# 7. Disconnect
ec.disconnectAutolab()| Method | Description |
|---|---|
connectToAutolab(hdw) |
Connect to instrument using hardware setup XML |
disconnectAutolab() |
Disconnect and release resources |
isConnected() |
Returns True if connected |
isMeasuring() |
Returns True if a measurement is running |
| Method | Description |
|---|---|
setPotential(V) |
Set cell potential (V) via autolab.Ei |
setCellOn(True/False) |
Turn cell on/off via autolab.Ei with overload protection |
setMode('Potentialstatic'/'Galvanostatic') |
Set workstation mode via autolab.Ei |
setCurrentRange(A) |
Set current range based on estimated current (A) |
wait(s) |
Blocking wait (s) |
| Method | Description |
|---|---|
loadProcedure(path) |
Load a .nox procedure file |
measure(procedure=None) |
Load (if needed) and execute measurement with real-time logging |
save() |
Save with timestamp suffix |
saveAs(name) |
Save to a specific path (timestamp appended) |
| Method | Description |
|---|---|
loadData(filename) |
Load data from .nox file into numpy array (CV or EIS) |
CV data format (columns): SetpointApplied, EI_0.CalcCurrent, CalcTime, ScanNumber
EIS data format (columns): Frequency, Zreal, Zimaginary, Zmodulus, -Phase
Access any command and parameter in any NOVA procedure by key name:
# Set a parameter before measurement
ec.setParameterDouble("FHCyclicVoltammetry2", "Upper vertex", 0.8)
ec.setParameterDouble("FHCyclicVoltammetry2", "Scanrate", 0.1)
# Read a parameter
upper = ec.getParameterDouble("FHCyclicVoltammetry2", "Upper vertex")
# Read measured data after measurement
potential = ec.getMeasuredPotential() # returns list
current = ec.getMeasuredCurrent()
time = ec.getMeasuredTime()| Method | Description |
|---|---|
getCommand(key) |
Get a Command object from the procedure |
getParameter(cmdKey, paramKey) |
Get a raw CommandParameter object |
setParameterDouble(...) |
Set double parameter |
setParameterDoubleList(...) |
Set double-list parameter |
setParameterInt(...) |
Set int parameter |
setParameterBool(...) |
Set bool parameter |
getParameterDouble(...) |
Get double parameter value |
getParameterDoubleList(...) |
Get double-list value |
getParameterInt(...) |
Get int parameter value |
getParameterBool(...) |
Get bool parameter value |
| Method | Description |
|---|---|
getOutputDouble(cmdKey, outKey) |
Read output double value |
getOutputDoubleList(cmdKey, outKey) |
Read output double-list value (time series) |
getMeasuredPotential() |
Convenience for CV potential array |
getMeasuredCurrent() |
Convenience for CV current array |
getMeasuredTime() |
Convenience for CV time array |
ec.setCVStartValue(0.0)
ec.setCVUpperVertex(0.8)
ec.setCVLowerVertex(-0.8)
ec.setCVStep(0.005)
ec.setCVIntervalTime(0.1)
ec.setCVScanRate(0.1)from pymetrohmautolab import AUTOLAB
# Command keys
AUTOLAB.CMD_CV_STAIRCASE # "FHCyclicVoltammetry2"
AUTOLAB.CMD_FRA_SCAN # "FIAScan"
AUTOLAB.CMD_RECORD_SIGNALS # "FHLevel"
# CV parameter keys
AUTOLAB.PARAM_START_VALUE # "Start value"
AUTOLAB.PARAM_UPPER_VERTEX # "Upper vertex"
AUTOLAB.PARAM_SCAN_RATE # "Scanrate"
# CV output keys
AUTOLAB.OUTPUT_POTENTIAL # "EI_0.CalcPotential"
AUTOLAB.OUTPUT_CURRENT # "EI_0.CalcCurrent"
AUTOLAB.OUTPUT_TIME # "CalcTime"ec.CMD = True # Enable real-time measurement logging (default)
ec.CMD = False # Disable loggingAll v0.0.4 methods are preserved:
AUTOLAB(sdk, adx)constructorsetSDKandADX(sdk, adx)connectToAutolab(hdw)disconnectAutolab()/Disconnect()measure(procedure)save()/saveAs(name)setPotential(potential)setCurrentRange(current_range)setCellOn(on)setMode(mode)wait(seconds)isMeasuring()loadData(filename)CMDLOGlogging utilityappendSuffixToFilename
Migration: zero code changes required for existing scripts.
- Close NOVA before running — the SDK cannot connect if NOVA holds the USB lock.
- Hardware setup path —
hdwmust point to the correctHardwareSetup.*.xmlfor your instrument (e.g.,PGSTAT204,PGSTAT302N,FRA32M). - SDK path — if your Autolab SDK is not in the default location, pass
sdkandadxto the constructor. - .NET compatibility —
pythonnetrequires the matching Python architecture (32-bit Python for 32-bit SDK, 64-bit for 64-bit). Most Autolab SDK installations are 32-bit. - numpy — required for
loadData()data extraction.
MIT License — see LICENSE.
This is an unofficial community package. Not affiliated with or endorsed by Metrohm Autolab.
See CHANGELOG.md.
See DIFF.md for a detailed line-by-line comparison.