Controlling Relays and Dry Contacts
The AT1000 provides 8 dry contact relays per device, which can be controlled individually or all at once. Each relay is addressed by its number (0-7).
Closing and Opening Relays​
the code snippets below demonstrate how to control the relays using the AT1000 API. The tester.relay() function is used to select a relay. The close() and open() methods are used to activate and deactivate the relay, respectively.
- NodeJS
- Python
import AT1000 from '@ikalogic/at1000';
let testers = await AT1000.findDevices(500); // Find the device with serial number 12345
let tester = testers[0]; // Pick the first detected device
let relay4 = tester.relays.relay(4); // Select relay number 4
await relay4.close(); // Close relay 4 (activate)
await relay4.open(); // Open relay 4 (deactivate)
from ikalogic_at1000 import AT1000
testers = AT1000.find_devices(500) # Find the device with serial number 12345
tester = testers[0] # Pick the first detected device
relay4 = tester.relays.relay(4) # Select relay number 4
await relay4.close() # Close relay 4 (activate)
await relay4.open() # Open relay 4 (deactivate)
Reading Relay Status
To check whether a relay is open or closed, use the read() function in a similar manner. This function returns 1 if the relay is closed and 0 if it is open.
- NodeJS
- Python
let relay_status = await relay4.read(); // Read the status of relay 4
console.log("Relay 4 status:" + relay_status );
relay_status = await relay4.read() # Read the status of relay 4
print("Relay 4 status:" + str(relay_status) )
Please note that relays operation are always sequential, and cannot be synchronized using the hold and release mechanisms described here.
API Reference​
Accessing Relays​
- NodeJS
- Python
const relays = tester.relays;
relays = tester.relays
Relays Module Methods​
reset()​
Resets all relays to their default state (open).
- NodeJS
- Python
await tester.relays.reset();
await tester.relays.reset()
Returns: Promise<void> / Awaitable[None]
relay(id)​
Access a specific relay by ID.
- NodeJS
- Python
const relay0 = tester.relays.relay(0);
relay0 = tester.relays.relay(0)
Parameters:
id(number/int): Relay identifier (0-7)
Returns: Relay instance
read()​
Reads the state of all relays at once.
- NodeJS
- Python
const states = await tester.relays.read();
console.log("All relay states:", states);
// ["open", "closed", "open", "open", "open", "open", "open", "open"]
states = await tester.relays.read()
print(f"All relay states: {states}")
# ["open", "closed", "open", "open", "open", "open", "open", "open"]
Returns: Promise<States> / Awaitable[States] - Array of states for all relays
open()​
Opens all relays simultaneously.
- NodeJS
- Python
await tester.relays.open();
await tester.relays.open()
Returns: Promise<States> / Awaitable[States] - Array of updated states (all "open")
close()​
Closes all relays simultaneously.
- NodeJS
- Python
await tester.relays.close();
await tester.relays.close()
Returns: Promise<States> / Awaitable[States] - Array of updated states (all "closed")
Relay Class​
Individual relay control.
id (Property)​
The relay identifier (read-only).
- NodeJS
- Python
console.log("Relay ID:", relay.id); // 0-7
print(f"Relay ID: {relay.id}") # 0-7
Type: number / int
read()​
Reads the current state of the relay.
- NodeJS
- Python
const state = await relay.read();
console.log("Relay is", state); // "open" or "closed"
state = await relay.read()
print(f"Relay is {state}") # "open" or "closed"
Returns: Promise<State> / Awaitable[State] - Either "open" or "closed"
is_open()​
Checks if the relay is open.
- NodeJS
- Python
const open = await relay.is_open();
if (open) {
console.log("Relay is open (circuit disconnected)");
}
open = await relay.is_open()
if open:
print("Relay is open (circuit disconnected)")
Returns: Promise<boolean> / Awaitable[bool] - true if open, false if closed
is_closed()​
Checks if the relay is closed.
- NodeJS
- Python
const closed = await relay.is_closed();
if (closed) {
console.log("Relay is closed (circuit connected)");
}
closed = await relay.is_closed()
if closed:
print("Relay is closed (circuit connected)")
Returns: Promise<boolean> / Awaitable[bool] - true if closed, false if open
open()​
Opens the relay (disconnects the circuit).
- NodeJS
- Python
await relay.open();
await relay.open()
Returns: Promise<State> / Awaitable[State] - The new state ("open")
close()​
Closes the relay (connects the circuit).
- NodeJS
- Python
await relay.close();
await relay.close()
Returns: Promise<State> / Awaitable[State] - The new state ("closed")
Types​
State​
"open" | "closed"
States​
Array<"open" | "closed"> // Length: 8 (one per relay)
Notes​
- Relays are dry contact type (no voltage provided by relay itself)
- 8 relays total (indexed 0-7)
- States:
"open"= circuit disconnected,"closed"= circuit connected - Relay 4 has special current measurement capability (see Power API)
- Default state after reset: all open
- Use appropriate delays between operations for mechanical relays