Skip to main content
Perform I2C (Inter-Integrated Circuit) data transfers with devices connected to a Lager Box. 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

The LabJack T7 maps the requested frequency to a clock throttle, up to about 450 kHz. If the T7 firmware refuses the computed throttle, the driver runs at the maximum rate and prints a warning.

LabJack U3

A U3 runs I2C through a firmware command of the U3, not through LJM. I2C on a U3 needs U3 hardware version 1.21 or later. The U3 is a bus master only. Pins: the default channel FIO6-FIO7 assigns SDA to FIO6 and SCL to FIO7. For other pins, create the net with lager nets add and the options --sda and --scl. FIO0-FIO3 cannot carry I2C. The EIO and CIO lines are on the DB15 connector of the U3. Pull-ups: the U3 has no pull-up resistors. Connect external resistors from SDA and from SCL to VS. LabJack recommends 4.7 kΩ. Without them, every address sends a NAK, and scan returns an empty list. --pull-ups has no effect on a U3, and config prints pull_ups=n/a (external resistors required). Limits:
  • A transfer writes at most 50 bytes and reads at most 52 bytes.
  • The clock runs from about 10 kHz to 150 kHz, and the box never runs it faster than the request. A request outside that range is clamped.
  • config prints the rate that the hardware uses, with the request in brackets when the two differ:
The CLI does not show a warning for a clamped clock, so read the rate in the config output. Errors: the U3 checks the acknowledgement of the address and of each byte that it writes. An error names the first byte that the device refused:
A write of 31 bytes or more reports only that a byte was refused, not which byte.

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
  • For LabJack U3: fit external pull-up resistors. The U3 has none, and without them a scan finds no devices
  • Confirm device power supply is connected

Bus Errors

  • LabJack T7: The first transaction after connection can return a bus error. This is normal, and the driver handles it 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 runs from about 130 Hz to 450 kHz. LabJack U3 runs from about 10 kHz to 150 kHz
  • config prints the clock rate that a LabJack U3 uses, which can differ from the request
  • 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