i2c-tiny-usb

Crates.ioi2c-tiny-usb
lib.rsi2c-tiny-usb
version0.1.0
created_at2025-03-04 10:34:38.712274+00
updated_at2025-03-04 10:34:38.712274+00
descriptionLibrary for communicating with USB-to-I2C adapters supporting the i2c-tiny-usb protocol
homepagehttps://github.com/tdudziak/i2c-tiny-usb-rs
repositoryhttps://github.com/tdudziak/i2c-tiny-usb-rs
max_upload_size
id1577073
size48,601
Tomasz Dudziak (tdudziak)

documentation

README

i2c-tiny-usb

A Rust library for communicating with USB-to-I2C adapters from userspace using libusb via the rusb crate. The library is compatible with a variety of USB adapters supported by the i2c-tiny-usb Linux kernel driver.

The library implements traits from the i2c crate so it can be used as a drop-in replacement for i2c-linux on non-Linux platforms if no other implementation is available.

Examples

You can find some example programs using the library in the examples/ directory. Most of them require some kind of extra hardware to be present on the I2C bus which is described in the top level comment of each example.

  • dump-eeprom.rs: Dumps content from an I2C EEPROM
  • i2cdetect.rs: Scans for devices on the I2C bus
  • sht35.rs: Reads temperature and humidity from an SHT35 sensor

Hardware Tests

Basic testcases can be simply run with cargo test but other tests require a pysical setup with an i2c-tiny-usb device present and an EEPROM chip connected to the I2C bus. Check the top level comment of hw_tests.rs for more details.

Run the hardware tests with:

cargo test --features hw-tests
Commit count: 17

cargo fmt