LibreVNA SCPI API

py
equipment
Published

November 3, 2026

LibreVNA SCPI API

LibreVNA primary user interface

The user interface for normal usage can be found in the LibreVNA github repository

There we find a Readme, therein we find debian packages for Ubuntu which can be installed on a Trixie instance of Debian GNU/Linux as well, if prerequsites are fulfilled. Just have a look at their releases. Following the instructions of the Readme it is easy to get it up and running.

If run, a fullscreen window shows a bunch of knobs and entry fields to the user for setting f.e. number of measurement points, starting and ending frequency numbers, and a menu with some useful items. You can choose the application: VNA, Spectum Analyser and All the documentation is written in LaTeXe to gain the most beautiful manuals as pdf, of course precompiled pdf files are included. To produce the pdf from the sources, an up2date texlive installation might be useful ;-)

Programming guide, SCPI

One of the pdf is aimed to the programming of the LibreVNA, there we find how it is intended to work: Inside the GUI menu items we find a SCPI-control, on which you can enable or disable a TCP-server process and it’s listening port number, 19542 is the default port.

SCPI is commonly used in measurement and control devices. To explore it, Debian helps with an lxi-gui interface for playing around…

Examples

For your convienience, some usage examples are there:

$ cd LibreVNA/Documentation/UserManual/SCPI_Examples
$ ls -1 *py
capture_live_data.py
deembedding_test.py
export_s11_s1p_csv.py
libreVNA.py
retrieve_trace_data.py
S11_calibration.py
simple_generator_control.py
$

For a smooth start up I find these extremely useful.

The libreVNA.py holds the interface to the tcp-port mentioned above and is imported inside the other Python snipplets. These programs are not complex and, of course, are learning examples only if you play something around with them. Comments inside them explain whts going on …

Ready to go

First I’ll start the most interesting part, calibration … Because only a calibrated device may be useful…

import time
from libreVNA import libreVNA

# Create the control instance
vna = libreVNA('localhost', 19542)

# Quick connection check (should print "LibreVNA-GUI")
print(vna.query("*IDN?"))
LibreVNA,LibreVNA-GUI,374B347C3435,1.6.5
# Make sure we are connecting to a device (just to be sure, 
# with default settings the LibreVNA-GUI auto-connects)
dev = vna.query(":DEV:CONN?")
if dev == "Not connected":
    print("Not connected to any device, aborting")
    exit(-1)
else:
    print("Connected to "+dev)
Connected to 374B347C3435
# Create the calibrations measurements. 
# This is necessary because the GUI starts with no calibration measurements by default.
# In case the GUI was already running, we clear the calibration measurements first.
vna.cmd("VNA:CAL:RESET")
vna.cmd("VNA:CAL:ADD OPEN")
vna.cmd("VNA:CAL:ADD SHORT")
vna.cmd("VNA:CAL:ADD LOAD")

# Set all three measurements to port 1 (just for clarity, 1 is already the default value)
vna.cmd("VNA:CAL:PORT 0 1")
vna.cmd("VNA:CAL:PORT 1 1")
vna.cmd("VNA:CAL:PORT 2 1")

def take_measurement(vna, cal_num):
    # start the measurement
    vna.cmd("VNA:CAL:MEAS "+str(cal_num))
    # wait for the measurement to complete
    while vna.query(":VNA:CAL:BUSY?") == "TRUE":
        time.sleep(0.1)
# Take the measurementss
input("Connect the OPEN standard and press ENTER to continue")
take_measurement(vna, 0);
input("Connect the SHORT standard and press ENTER to continue")
take_measurement(vna, 1);
input("Connect the LOAD standard and press ENTER to continue")
take_measurement(vna, 2);

# Activate the calibration
vna.cmd("VNA:CAL:ACT SOLT_1")

# Readback active calibration type
print("Active calibration: "+vna.query("VNA:CAL:ACTIVE?"))
Connect the OPEN standard and press ENTER to continue
Connect the SHORT standard and press ENTER to continue
Connect the LOAD standard and press ENTER to continue
Active calibration: SOLT_1

This has been a rather simple calibration and it worked out of the repository transferred into this jupyter-notebook.

The calibration itself is valid until the next calibration happend or the gui is powered off. Especially it is not saved for now.

Before continuing, I have to read more in the programing guide about those commands needed.

Have Fun!