Userspace I2C Utilities for Linux
C Makefile
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
Makefile
README.md
STATUS
TODO
ui2c-ds1307.c
ui2c-mlx90614.c
ui2c-ssd1306.c
ui2c-tea5767.c
ui2c-tmp007.c
ui2c_ssd1306_test_sprite.png
ui2c_ssd1306_test_static.png

README.md

Userspace I2C Utilities for Linux

These utilities let you use I2C peripherals without kernel driver. Devices such as SSD1306 have kernel drivers that are hotplug-allergic. A userspace tool is way safer, although has lower efficiency.

CURRENTLY UNDER HEAVY DEVELOPMENT.

See STATUS for detailed progresses.

Since I have little spare time now, expect inactivities.

Patches and PRs are welcome!

Usage

General

  • Identify a usable I2C master. See I2C Masters.
  • Scan it with i2cdetect tool from i2c-tools to confirm the devices are connected properly (so they are present). e.g. i2cdetect -l then i2cdetect 1 for bus i2c-1.
  • Compile and use the corresponding utilites for each device. You can compile individually by using make [target].

I2C Masters

I2C on VGA port (DDC)

Pinout:

----------------------
\   5  4  3  2  1    /
 \   10 9  8  7  6  /
  \ 15 14 13 12 11 /
   ----------------
  • 5: GND
  • 9: +5V (not always available)
  • 12: SDA
  • 15: SCL

Tested on:

  • Acer Aspire 4741G (proprietary driver, "NVIDIA i2c adapter 0 at 2:00.0", external power required as VGA only supplies ~ 1V)
  • Dell Latitude E5430 ("i915 gmbus vga")

I2C on Beaglebone Black

AM335x does not support 400kHz I2C bus, thus no fast writes. For i2c-tools, you want to use the "-r" flag.

Not tested yet.

I2C on Raspberry Pi

Not tested yet.

Devices that will NOT get supported (for now)

24xx EEPROM

The eeprom kernel module is time-proven, hotplug-safe and easy to use. To register a device, simply do something like the following:

echo eeprom 0x50 > /sys/bus/i2c/devices/i2c-x/new_device
cat /sys/bus/i2c/devices/x-0050/eeprom | hd

For more details see the kernel document. Besides, it is quite easy to use i2cdump from i2c-tools to read it from userspace.

PN532 NFC

The libnfc project provides many userspace tools to communicate with the chip over UART/I2C/SPI. See libnfc on github for repository and Lady Ada's instructions for a general tutorial, and also Libnfc:configuration for how to specify devices. When scanning for device, you might need the -i (intrusive) flag. The bad thing is that you can not control which I2C bus it scans.

MPU-9150 MEMS-IMU

There is a userspace tool that can control the IMU over I2C. Tested with Beaglebone Black. The DMP firmware is embedded. You may want to fix some of its algorithm or force it to print some low-level compass heading.