The Keysight B2902B and B2912B source meter is controlled remotely with SCPI commands. TestFlow's instrument library holds 62 commands for it, 15 of them queries that read values or state, grouped below by subsystem with their arguments. It is the same library TestFlow's AI agent uses to drive the B2902B on a real bench.
Describe the test; TestFlow's agent uses this command set to drive your Keysight B2902B or B2912B and writes the report from the measured results.
With PyVISA, any VISA backend, and the instrument on USB, LAN or GPIB, this opens a session, identifies the instrument, sends one setting, and reads one value. Every command in it comes from the reference below. For a full walkthrough, see the PyVISA tutorial and the SCPI command cheat sheet.
import pyvisa
rm = pyvisa.ResourceManager()
print(rm.list_resources()) # find the Keysight B2902B's VISA address
# Paste the address of your Keysight B2902B (USB, LAN or GPIB).
inst = rm.open_resource("PASTE_VISA_ADDRESS_HERE")
inst.timeout = 5000 # ms
print(inst.query("*IDN?")) # identify the instrument
inst.write(":OUTPut1 ON") # Turn On
print(inst.query(":MEASure:VOLTage? (@1)")) # Measure Voltage
inst.close()Describe the test; TestFlow's agent uses this command set to drive your Keysight B2902B or B2912B and writes the report from the measured results.
Describe the test in a sentence, for example “turn on on the B2902B, then measure voltage and log it against a limit”. TestFlow's agent builds the steps from this command library, runs them on your bench through the TestFlow desktop app, and writes the report from the measured values. See AI test automation for lab instruments for how that works and where it stops.
62 commands in 16 groups. A ? marks a query that returns a value. Placeholders in angle brackets take the listed values. The B2902B and B2912B share this command set in TestFlow's library.
| Command | What it does | Arguments |
|---|---|---|
| :SOURce<Channel>:FUNCtion:SHAPe <Function> | Set Source Function. Sets the source output shape (DC or Pulse) for the specified channel. | Number: 1,2; Text: DC,PULSe |
| :SOURce<Channel>:FUNCtion:MODE <Mode> | Set Source Mode. Sets the source function mode (voltage or current sourcing) for the specified channel. | Number: 1,2; Text: VOLTage,CURRent |
| :SOURce<Channel>:VOLTage:LEVel:IMMediate:AMPLitude <Voltage> | Set Voltage. Sets the DC output voltage level in volts for the specified channel (range: -21 V to +21 V). | Number: 1,2; Number |
| :SOURce<Channel>:CURRent:LEVel:IMMediate:AMPLitude <Current> | Set Current. Sets the DC output current level in amperes for the specified channel (range: -3 A to +3 A). | Number: 1,2; Number |
| :SOURce<Channel>:VOLTage:RANGe <Range> | Set Voltage Range. Sets the voltage source output range in volts for the specified channel (0.2 V / 2 V / 20 V). | Number: 1,2; Number: 0.2,2,20 |
| :SOURce<Channel>:CURRent:RANGe <Range> | Set Current Range. Sets the current source output range in amperes for the specified channel. | Number: 1,2; Number: 100e-9,1e-6,10e-6,100e-6,1e-3,10e-3,100e-3,1,3 |
| :SOURce<Channel>:VOLTage:RANGe:AUTO <State> | Set Voltage Auto Range. Enables or disables auto-range for the voltage source output of the specified channel. | Number: 1,2; Text: ON,OFF |
| :SOURce<Channel>:CURRent:RANGe:AUTO <State> | Set Current Auto Range. Enables or disables auto-range for the current source output of the specified channel. | Number: 1,2; Text: ON,OFF |
| :SOURce<Channel>:VOLTage:LEVel:TRIGgered:AMPLitude <Voltage> | Set Triggered Voltage. Sets the triggered voltage source level for the specified channel applied on the next trigger event. | Number: 1,2; Number |
| :SOURce<Channel>:CURRent:LEVel:TRIGgered:AMPLitude <Current> | Set Triggered Current. Sets the triggered current source level for the specified channel applied on the next trigger event. | Number: 1,2; Number |
| :SOURce<Channel>:<Function>:STARt <Value> | Set Sweep Start. Sets the start value for a sweep on the specified channel and source function. | Number: 1,2; Text: VOLTage,CURRent; Number |
| :SOURce<Channel>:<Function>:STOP <Value> | Set Sweep Stop. Sets the stop value for a sweep on the specified channel and source function. | Number: 1,2; Text: VOLTage,CURRent; Number |
| :SOURce<Channel>:<Function>:STEP <Value> | Set Sweep Step. Sets the step size for a linear sweep on the specified channel and source function. | Number: 1,2; Text: VOLTage,CURRent; Number |
| :SOURce<Channel>:<Function>:POINts <Points> | Set Sweep Points. Sets the number of data points for a source sweep on the specified channel. | Number: 1,2; Text: VOLTage,CURRent; Number |
| Command | What it does | Arguments |
|---|---|---|
| :SENSe<Channel>:VOLTage:PROTection:LEVel <Voltage> | Set Voltage Compliance. Sets the voltage compliance (protection) limit in volts for the specified channel when sourcing current. | Number: 1,2; Number |
| :SENSe<Channel>:CURRent:PROTection:LEVel <Current> | Set Current Compliance. Sets the current compliance (protection) limit in amperes for the specified channel when sourcing voltage. | Number: 1,2; Number |
| :SENSe<Channel>:FUNCtion:ON "<Function>" | Set Sense Function. Selects the measurement (sense) function for the specified channel. | Number: 1,2; Text: VOLTage,CURRent,RESistance |
| :SENSe<Channel>:VOLTage:RANGe:UPPer <Range> | Set Sense Voltage Range. Sets the voltage measurement range for the specified channel in volts. | Number: 1,2; Number: 0.2,2,20 |
| :SENSe<Channel>:CURRent:RANGe:UPPer <Range> | Set Sense Current Range. Sets the current measurement range for the specified channel in amperes. | Number: 1,2; Number: 100e-9,1e-6,10e-6,100e-6,1e-3,10e-3,100e-3,1,3 |
| :SENSe<Channel>:<Function>:RANGe:AUTO <State> | Set Sense Auto Range. Enables or disables auto-range for the selected sense function on the specified channel. | Number: 1,2; Text: VOLTage,CURRent,RESistance; Text: ON,OFF |
| :SENSe<Channel>:<Function>:NPLCycles <NPLC> | Set NPLC. Sets the integration time in power line cycles (NPLC) for the sense function of the specified channel. | Number: 1,2; Text: VOLTage,CURRent,RESistance; Number: 0.01,0.1,1,10 |
| :SENSe<Channel>:<Function>:APERture <Seconds> | Set Aperture. Sets the measurement aperture (integration time in seconds) for the specified channel and sense function. | Number: 1,2; Text: VOLTage,CURRent,RESistance; Number |
| :SENSe<Channel>:REMote <State> | Set Remote Sense. Enables or disables 4-wire (Kelvin) remote sensing for the specified channel. | Number: 1,2; Text: ON,OFF |
| :SENSe<Channel>:<Function>:PROTection:TRIPped? | Check Compliance. Queries whether a compliance trip event has occurred on the specified channel and function. | Number: 1,2; Text: VOLTage,CURRent |
| Command | What it does | Arguments |
|---|---|---|
| :OUTPut<Channel> ON | Turn On. Enables the output of the specified channel (1 or 2). | Number: 1,2 |
| :OUTPut<Channel> OFF | Turn Off. Disables the output of the specified channel (1 or 2). | Number: 1,2 |
| :OUTPut<Channel>:STATe? | Read Output State. Queries and returns the output state of the specified channel (0=OFF / 1=ON). | Number: 1,2 |
| :OUTPut<Channel>:OFF:MODE <Mode> | Set Output Off Mode. Sets the terminal condition when the output of the specified channel is turned off. | Number: 1,2; Text: NORMal,ZERO,HIZ |
| :OUTPut<Channel>:LOW <State> | Set Output Low. Sets the output LO terminal to ground or floating for the specified channel when output is off. | Number: 1,2; Text: GROund,FLOat |
| :OUTPut<Channel>:FILTer:LPASs:STATe <State> | Set Output Filter. Enables or disables the output low-pass filter for the specified channel. | Number: 1,2; Text: ON,OFF |
| :OUTPut<Channel>:FILTer:LPASs:FREQuency <Frequency> | Set Filter Frequency. Sets the output low-pass filter cutoff frequency in Hz for the specified channel. | Number: 1,2; Number: 31.83-31831 |
| Command | What it does | Arguments |
|---|---|---|
| :FETCh:SCALar:VOLTage? (@<Channel>) | Fetch Voltage. Returns the last measured voltage of the specified channel from buffer without re-triggering. | Number: 1,2 |
| :FETCh:SCALar:CURRent? (@<Channel>) | Fetch Current. Returns the last measured current of the specified channel from buffer without re-triggering. | Number: 1,2 |
| :FETCh:SCALar? (@<Channel>) | Fetch All. Returns all last measured data (voltage current resistance status timestamp) for the specified channel. | Number: 1,2 |
| :FETCh:ARRay:VOLTage? (@<Channel>) | Fetch Array Voltage. Returns the array of measured voltage data points from the last sweep for the specified channel. | Number: 1,2 |
| :FETCh:ARRay:CURRent? (@<Channel>) | Fetch Array Current. Returns the array of measured current data points from the last sweep for the specified channel. | Number: 1,2 |
| Command | What it does | Arguments |
|---|---|---|
| :MEASure:VOLTage? (@<Channel>) | Measure Voltage. Triggers a measurement and returns the measured voltage of the specified channel in volts. | Number: 1,2 |
| :MEASure:CURRent? (@<Channel>) | Measure Current. Triggers a measurement and returns the measured current of the specified channel in amperes. | Number: 1,2 |
| :MEASure:RESistance? (@<Channel>) | Measure Resistance. Triggers a measurement and returns the measured resistance of the specified channel in ohms. | Number: 1,2 |
| Command | What it does | Arguments |
|---|---|---|
| :READ:SCALar? (@<Channel>) | Read Scalar. Triggers a single measurement and returns all enabled data for the specified channel as a scalar. | Number: 1,2 |
| :READ:ARRay? (@<Channel>) | Read Array. Triggers a sweep and returns all data points as an array for the specified channel. | Number: 1,2 |
| Command | What it does | Arguments |
|---|---|---|
| :TRIGger:COUNt <Count> | Set Trigger Count. Sets the number of trigger events (measurement points) in a single measurement sequence (global). | Number |
| :TRIGger:DELay <Seconds> | Set Trigger Delay. Sets the delay in seconds between the trigger event and measurement start (global). | Number |
| Command | What it does | Arguments |
|---|---|---|
| :DISPlay:ENABle <State> | Set Display Enable. Enables or disables the front-panel display. Disabling improves measurement throughput. | Text: ON,OFF |
| :DISPlay:WINDow:TEXT:DATA <String> | Set Display Text. Sends a user-defined text string to be shown on the front panel display. | Text |
| Command | What it does | Arguments |
|---|---|---|
| :FORMat:ELEMents:SENSe <Elements> | Set Format Elements. Selects which data elements are included in the measurement output string for all channels. | Text: VOLTage,CURRent,RESistance,TIME,STATus,SOURce |
| :FORMat:DATA <Format> | Set Data Format. Sets the output data format for measurement results (ASCII or binary) for all channels. | Text: ASCii,REAL,32,REAL,64 |
| Command | What it does | Arguments |
|---|---|---|
| :ARM:COUNt <Count> | Set Arm Count. Sets the number of times the trigger layer is executed per arm event (global). | Number |
| Command | What it does | Arguments |
|---|---|---|
| :INITiate:IMMediate | Initiate Trigger. Initiates a measurement sequence on all channels by moving the instrument from idle to arm layer. | None |
| Command | What it does | Arguments |
|---|---|---|
| :ABORt | Abort Trigger. Aborts any in-progress measurement sequence on all channels and returns instrument to idle state. | None |
| Command | What it does | Arguments |
|---|---|---|
| <Output Variable>=<Equation> | Math. Variable equals an equation like (${Var_name}= ${Var_name}/2) | Number; Text |
| Command | What it does | Arguments |
|---|---|---|
| wait(<ms>) | Wait. Waits for number of milliseconds | Number |
| Command | What it does | Arguments |
|---|---|---|
| save2var <Variable_name> | Save2Variable. Saves last measurement to a variable | Text |
| Command | What it does | Arguments |
|---|---|---|
| *SAV <Register> | Save State. Saves the current instrument settings (both channels) to non-volatile memory register (0 to 4). | Number: 0,1,2,3,4 |
| *RCL <Register> | Recall State. Recalls and restores instrument settings (both channels) from the specified non-volatile memory register. | Number: 0,1,2,3,4 |
| *IDN? | Identify. Queries and returns the instrument identification string (manufacturer model serial firmware). | None |
| *RST | Reset. Resets the instrument to factory default settings on all channels and aborts any pending operations. | None |
| *TST? | Self Test. Executes the instrument self-test and returns 0 if passed or a non-zero error code if failed. | None |
| *CAL? | Self Calibration. Executes self-calibration for all channels and returns 0 if successful or a non-zero error code if failed. | None |
| *CLS | Clear Status. Clears the event status registers and the error queue. | None |
| *OPC | Operation Complete. Sets the OPC bit in the Event Status Register when all pending operations on all channels are complete. | None |
| *WAI | Wait For Complete. Prevents the instrument from executing further commands until all pending operations are complete. | None |
This reference is generated from TestFlow's instrument library, which is drafted from Keysight's programming documentation for the B2902B and B2912B and checked when the agent runs it. Ranges, timing, and option-dependent commands are defined by Keysight's programming manual: check it before you rely on an edge case. Last updated November 12, 2026.
Yes. The Keysight B2902B accepts SCPI commands over its remote interfaces. TestFlow's instrument library holds 62 SCPI commands for it: 15 queries that read values or state, and 47 settings and actions.
Install PyVISA and a VISA backend, find the instrument's address with ResourceManager().list_resources(), open it, then send commands with write() and read values with query(). The example on this page sends *IDN?, :OUTPut1 ON and :MEASure:VOLTage? (@1).
:MEASure:VOLTage? (@1) (measure voltage). Triggers a measurement and returns the measured voltage of the specified channel in volts. The full list of queries is in the command reference on this page, grouped by subsystem.
Yes. TestFlow is an AI agent for electronics testing: you describe the test, and it builds the automation from this command library, runs it on the Keysight B2902B through the TestFlow desktop app, and writes the report from the measured results.
Describe the test. TestFlow builds the workflow, runs it on your instruments, and writes the report. See it on a bench like yours.