Skip to main content
Perform I2C (Inter-Integrated Circuit) data transfers with devices connected to a Lagerbox. I2C is a synchronous serial protocol using two lines: SDA (data) and SCL (clock).

Syntax

Arguments

Options

When invoked without a subcommand, lists I2C nets on the box (or shows configuration for the specified net).

Subcommands

config

Configure I2C bus parameters. Settings persist across subsequent commands.
Examples:

scan

Scan the I2C bus for connected devices. Probes each address and reports those that respond with an ACK.
The default range 0x08-0x77 excludes reserved I2C addresses. Examples:

read

Read bytes from an I2C device.
Examples:

write

Write bytes to an I2C device.
Provide data either as the 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.
Examples:

Hex Data Formats

Data arguments accept multiple hex formats: All values must be within byte range (0x00-0xFF).

Address Format

I2C addresses are 7-bit values (0x00-0x7F). You can specify addresses in hex or decimal:

Frequency Format

Clock frequencies accept numeric values with optional suffixes:

Supported Hardware


Net Configuration

I2C nets are configured in saved_nets.json on the box. Example net record:
For Aardvark adapters:

Output Formats


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 on to 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 transfer command uses I2C repeated start for atomic write-then-read operations

See Also

  • SPI — SPI bus communication (the other common serial protocol)
  • Python I2C API — Automate I2C operations in Python scripts
  • Glossary — Definitions of I2C, SPI, and other terms