Syntax
Arguments
| Argument | Description |
|---|---|
NETNAME | I2C net name (optional if default is set via lager defaults add --i2c-net) |
Options
| Option | Description |
|---|---|
--box BOX | Lagerbox name or IP address |
Subcommands
config
Configure I2C bus parameters. Settings persist across subsequent commands.
| Option | Description |
|---|---|
--box BOX | Lagerbox name or IP address |
--frequency FREQ | Clock frequency (e.g., 100k, 400k, 1M) |
--pull-ups on|off | Enable/disable internal pull-ups (Aardvark only) |
scan
Scan the I2C bus for connected devices. Probes each address and reports those that respond with an ACK.
| Option | Description | Default |
|---|---|---|
--box BOX | Lagerbox name or IP address | |
--start ADDR | Start address in hex | 0x08 |
--end ADDR | End address in hex | 0x77 |
0x08-0x77 excludes reserved I2C addresses.
Examples:
read
Read bytes from an I2C device.
| Argument | Description |
|---|---|
NUM_BYTES | Number of bytes to read (0 or more) |
| Option | Description | Default |
|---|---|---|
--box BOX | Lagerbox name or IP address | |
--address ADDR | Device address in hex (e.g., 0x48) | Required |
--frequency FREQ | Clock frequency override (e.g., 100k, 400k) | |
--format FORMAT | Output format: hex, bytes, json | hex |
write
Write bytes to an I2C device.
| Argument | Description |
|---|---|
DATA | Hex data to write (e.g., 0x0A03, 0a 03, 0a,03) |
| Option | Description | Default |
|---|---|---|
--box BOX | Lagerbox name or IP address | |
--address ADDR | Device address in hex (e.g., 0x48) | Required |
--data-file PATH | File containing binary data to write | |
--frequency FREQ | Clock frequency override | |
--format FORMAT | Output format: hex, bytes, json | hex |
DATA argument or via --data-file, but not both.
Examples:
transfer
Write then read in a single I2C transaction using a repeated start condition. This is the standard pattern for reading registers: write the register address, then read the register value without releasing the bus.
| Argument | Description |
|---|---|
NUM_BYTES | Number of bytes to read (0 or more) |
| Option | Description | Default |
|---|---|---|
--box BOX | Lagerbox name or IP address | |
--address ADDR | Device address in hex (e.g., 0x48) | Required |
--data DATA | Hex data to write before reading (e.g., register address) | |
--data-file PATH | File containing data to write before reading | |
--frequency FREQ | Clock frequency override | |
--format FORMAT | Output format: hex, bytes, json | hex |
Hex Data Formats
Data arguments accept multiple hex formats:| Format | Example | Parsed As |
|---|---|---|
| Prefixed continuous | 0x0a03 | [0x0a, 0x03] |
| Unprefixed continuous | 0a03 | [0x0a, 0x03] |
| Space-separated | 0a 03 | [0x0a, 0x03] |
| Comma-separated | 0a,03 | [0x0a, 0x03] |
| Single byte | 0x0a | [0x0a] |
0x00-0xFF).
Address Format
I2C addresses are 7-bit values (0x00-0x7F). You can specify addresses in hex or decimal:
| Format | Example | Value |
|---|---|---|
| Hex prefixed | 0x48 | 72 |
| Hex unprefixed | 48 | 72 |
| Decimal | 72 | 72 |
Frequency Format
Clock frequencies accept numeric values with optional suffixes:| Format | Example | Value |
|---|---|---|
| Plain Hz | 100000 | 100 kHz |
| kHz suffix | 100k | 100 kHz |
| MHz suffix | 1M | 1 MHz |
| Hz suffix | 400000hz | 400 kHz |
Supported Hardware
| Adapter | Pins | Pull-ups | Notes |
|---|---|---|---|
| LabJack T7 | Configurable FIO pins (e.g., FIO4/FIO5) | External only | ~450 kHz max (throttle=0) |
| Aardvark USB | Fixed SDA/SCL | Internal (switchable) | Up to 800 kHz |
| FT232H | Configurable | External only | MPSSE-based I2C |
Net Configuration
I2C nets are configured insaved_nets.json on the box. Example net record:
Output Formats
| Format | Description |
|---|---|
hex | Space-separated hex bytes (e.g., 0a 03 ff) |
bytes | Raw byte values |
json | JSON object with data array and metadata |
Examples
Troubleshooting
No Devices Found on Scan
- Verify SDA and SCL wiring
- Check that pull-up resistors are present (4.7k typical for 100kHz)
- For Aardvark: try
--pull-ups onto enable internal pull-ups - Confirm device power supply is connected
Bus Errors
- LabJack T7: The first transaction after connection may return a bus error; this is normal and handled automatically
- Try reducing frequency with
--frequency 100k - Check for bus contention (multiple masters)
NACK Errors
- Verify the device address (some datasheets show 8-bit shifted addresses)
- Ensure the device is powered and not in reset
- Check for address conflicts with other devices on the bus
Notes
- Default I2C net can be set with
lager defaults add --i2c-net NETNAME - LabJack T7 operates at ~450 kHz regardless of requested frequency due to hardware limitations
- Aardvark adapters support internal pull-ups that can be toggled via
config --pull-ups - The
transfercommand uses I2C repeated start for atomic write-then-read operations

