
Read and Write I2C Registers With i2cget, i2cset and i2ctransfer
Read and write device registers from the shell with i2cget, i2cset, i2cdump and i2ctransfer from i2c-tools 4.3, using a TMP102 sensor as the worked example.
Tag
7 posts

Read and write device registers from the shell with i2cget, i2cset, i2cdump and i2ctransfer from i2c-tools 4.3, using a TMP102 sensor as the worked example.

Enable /dev/i2c-N, list adapters with i2cdetect -l, scan a bus with i2cdetect -y and read the address grid, including reserved ranges and missing devices.

Blink an LED, read a button and wait for edge events from Python 3.12 with the libgpiod 2.1 gpiod module, using request_lines and LineSettings.

Drive an LED and read a button from the shell with gpioset and gpioget from libgpiod 2.1 on Linux 6.12, including toggling, timed pulses and bias.

List GPIO chips with gpiodetect and read every line's name, direction and consumer with gpioinfo from libgpiod 2.1 on Linux 6.12, then pick the line you want.

The /sys/class/gpio interface is deprecated in Linux 6.12 because of unstable numbering, leaked pins, races and missing features. Here is what replaced it.

Drive GPIO lines, I2C sensors and SPI devices from Linux userspace with libgpiod, i2c-tools and spidev in C, Python and Rust, plus device tree and permissions.