GPIO API Reference
The GPIO (General Purpose Input/Output) API provides access to 32 programmable I/O pins that can be configured for digital or analog operations. Each pin supports voltages from -25V to +25V for inputs and 0 to 24V for outputs.
Accessing GPIO​
- NodeJS
- Python
const gpio = tester.gpio;
gpio = tester.gpio
GPIO Module Methods​
reset()​
Resets all GPIO pins to their default configuration.
- NodeJS
- Python
await tester.gpio.reset();
await tester.gpio.reset()
Returns: Promise<void> / Awaitable[None]
digital(io)​
Access a specific GPIO pin for digital operations.
- NodeJS
- Python
const pin = tester.gpio.digital(0);
pin = tester.gpio.digital(0)
Parameters:
io(number/int): GPIO pin number (0-31)
Returns: DigitalIO instance
analog(io)​
Access a specific GPIO pin for analog operations.
- NodeJS
- Python
const pin = tester.gpio.analog(0);
pin = tester.gpio.analog(0)
Parameters:
io(number/int): GPIO pin number (0-31)
Returns: AnalogIO instance
hold()​
Holds (freezes) the current state of all GPIO pins. This allows buffering multiple write commands before applying them simultaneously.
- NodeJS
- Python
await tester.gpio.hold();
await tester.gpio.hold()
Returns: Promise<SyncConfiguration> / Awaitable[SyncConfiguration] - Configuration with action: "hold"
Prevents external changes to GPIO states until release() is called. All write operations between hold() and release() are buffered.
release()​
Releases control of GPIO pins, applying all buffered writes simultaneously. This also sets the device as a slave.
- NodeJS
- Python
await tester.gpio.release();
await tester.gpio.release()
Returns: Promise<SyncConfiguration> / Awaitable[SyncConfiguration] - Configuration with action: "release"
DigitalIO Class​
configure_input(config) / config_input(config)​
Configures the pin as a digital input with custom thresholds.
- NodeJS
- Python
await pin.configure_input({
vil: 0.8, // Input low threshold
vih: 2.0 // Input high threshold
});
await pin.config_input({"vil": 0.8, "vih": 2.0})
Parameters:
config(PartialDigitalInputConfiguration):vil(number/float, required): Voltage input low threshold (-25 to 25V)vih(number/float, required): Voltage input high threshold (-25 to 25V)
Returns: Promise<DigitalInputConfiguration> / Awaitable[DigitalInputConfiguration] - Full configuration including mode and direction
Exceptions:
- Throws validation error if
vilorvihis outside the range [-25, 25]
configure_output(config) / config_output(config)​
Configures the pin as a digital output with custom voltage levels and thresholds.
- NodeJS
- Python
await pin.configure_output({
value: true, // Initial state
vol: 0.0, // Output low voltage
voh: 3.3, // Output high voltage
vil: 0.8, // Optional input low threshold
vih: 2.0 // Optional input high threshold
});
await pin.config_output({
"value": True, # Initial state
"vol": 0.0, # Output low voltage
"voh": 3.3, # Output high voltage
"vil": 0.8, # Optional input low threshold
"vih": 2.0 # Optional input high threshold
})
Parameters:
config(PartialDigitalOutputConfiguration):value(boolean | number/bool | int, required): Initial output state (true/1 = high, false/0 = low)vol(number/float, required): Voltage output low level (0 to 24V)voh(number/float, required): Voltage output high level (0 to 24V)vil(number/float, optional): Voltage input low threshold (-25 to 25V)vih(number/float, optional): Voltage input high threshold (-25 to 25V)
Returns: Promise<DigitalOutputConfiguration> / Awaitable[DigitalOutputConfiguration] - Full configuration
Exceptions:
- Throws validation error if
volorvohis outside the range [0, 24] - Throws validation error if
vilorvihis outside the range [-25, 25]
When vil and vih are omitted, they are automatically deduced from the given voh and vol parameters.
configure_open_drain(config) / config_open_drain(config)​
Configures the pin as an open-drain output (useful for I2C, 1-Wire, etc.).
- NodeJS
- Python
await pin.configure_open_drain({
value: true,
vil: 0.8,
vih: 2.0
});
await pin.config_open_drain({
"value": True,
"vil": 0.8,
"vih": 2.0
})
Parameters:
config(PartialOpenDrainConfiguration):value(boolean | number/bool | int, required): Initial state (true = floating/high-Z, false = low)vil(number/float, required): Voltage input low threshold (-25 to 25V)vih(number/float, required): Voltage input high threshold (-25 to 25V)
Returns: Promise<OpenDrainConfiguration> / Awaitable[OpenDrainConfiguration] - Full configuration
Exceptions:
- Throws validation error if
vilorvihis outside the range [-25, 25]
read()​
Reads the current logical state of the pin.
- NodeJS
- Python
const state = await pin.read();
console.log("Pin is", state ? "HIGH" : "LOW");
state = await pin.read()
print("Pin is", "HIGH" if state else "LOW")
Returns: Promise<boolean> / Awaitable[bool] - true for HIGH, false for LOW
write(value)​
Writes a logical value to the pin (must be configured as output).
- NodeJS
- Python
await pin.write(true); // Set HIGH
await pin.write(false); // Set LOW
await pin.write(1); // Set HIGH (numeric)
await pin.write(0); // Set LOW (numeric)
await pin.write(True) # Set HIGH
await pin.write(False) # Set LOW
await pin.write(1) # Set HIGH (numeric)
await pin.write(0) # Set LOW (numeric)
Parameters:
value(boolean | number/bool | int): Value to write (true/1 = HIGH, false/0 = LOW)
Returns: Promise<boolean> / Awaitable[bool] - The written value as boolean
AnalogIO Class​
configure_input() / config_input()​
Configures the pin as an analog input for voltage measurement.
- NodeJS
- Python
await pin.configure_input();
await pin.config_input()
Returns: Promise<AnalogInputConfiguration> / Awaitable[AnalogInputConfiguration] - Configuration with mode "analog" and direction "input"
configure_output(value) / config_output(value)​
Configures the pin as an analog output and sets the initial voltage.
- NodeJS
- Python
await pin.configure_output(3.3); // Set to 3.3V
await pin.config_output(3.3) # Set to 3.3V
Parameters:
value(number/float): Initial output voltage (0 to 24V)
Returns: Promise<AnalogOutputConfiguration> / Awaitable[AnalogOutputConfiguration] - Full configuration
Exceptions:
- Throws validation error if value is outside the range [0, 24]
read()​
Reads the current analog voltage at the pin.
- NodeJS
- Python
const voltage = await pin.read();
console.log("Voltage:", voltage, "V");
voltage = await pin.read()
print(f"Voltage: {voltage} V")
Returns: Promise<number> / Awaitable[float] - Measured voltage in volts
write(value)​
Sets the analog output voltage (must be configured as analog output).
- NodeJS
- Python
await pin.write(3.3); // Set to 3.3V
await pin.write(5.0); // Set to 5.0V
await pin.write(12.5); // Set to 12.5V
await pin.write(3.3) # Set to 3.3V
await pin.write(5.0) # Set to 5.0V
await pin.write(12.5) # Set to 12.5V
Parameters:
value(number/float): Voltage to output (0 to 24V)
Returns: Promise<number> / Awaitable[float] - The set voltage
Exceptions:
- Throws validation error if value is outside the range [0, 24]
Types​
DigitalInputConfiguration​
{
mode: "digital",
direction: "input",
vil: number, // -25 to 25V
vih: number // -25 to 25V
}
DigitalOutputConfiguration​
{
mode: "digital",
direction: "output",
value: boolean,
vol: number, // 0 to 24V
voh: number, // 0 to 24V
vil: number, // -25 to 25V
vih: number // -25 to 25V
}
OpenDrainConfiguration​
{
mode: "digital",
direction: "open_drain",
value: boolean,
vil: number, // -25 to 25V
vih: number // -25 to 25V
}
AnalogInputConfiguration​
{
mode: "analog",
direction: "input"
}
AnalogOutputConfiguration​
{
mode: "analog",
direction: "output",
value?: number // 0 to 24V
}
Notes​
- All 32 pins support both digital and analog modes
- Voltage range: -25V to +25V for inputs, 0 to 24V for outputs
- Digital thresholds (
vil/vih) can be set independently for precise logic level detection - Open-drain mode is ideal for protocols requiring external pull-ups (I2C, 1-Wire)
- When writing digital values, both
booleanandnumber(0/1) are accepted - Analog readings provide precise voltage measurements
- Use
hold()andrelease()for synchronized multi-pin operations