Project

i2c

0.03
No release in over 3 years
Low commit activity in last 3 years
Interface to I2C (aka TWI) implementations. Also provides abstractions for some I2c-devices. Created with the Raspberry Pi in mind.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

I2C - Ruby I2C library¶ ↑

About¶ ↑

Interface to Linux I2C (a.k.a. TWI) implementations. Right now targeted at the Raspberry Pi, but should work with any linux i2c-dev I2C-hardware.

Structure¶ ↑

The library is split into two parts:

  • A backend for accessing the I2C bus (right now only through the i2c-dev

in Linux, other impementations are possible).

  • Drivers for I2C enabled ICs.

Installation¶ ↑

To use the i2c-dev backend it is necessary to load the “i2c-dev” linux kernel module. This is not done automatically even if the module for the underlying I2C-hardware is. To automatically load the i2c-dev driver on startup add it to /etc/modules. Also the device file (usually /dev/i2c-0) must be user accessible. A working (at least on a RaspberryPi running Raspbian) udev rule file is available (rules/88-i2c.rules) and can be installed to /etc/udev/rules.d/.

Backends¶ ↑

The backends are instantiated through the #I2C::create method. depending on the format of the passed bus descriptor the correct backend is invoked.

Right now there is only a i2c-dev backend available

i2c-dev Backend¶ ↑

Backend for the Linux I2C implementation. Accepts device file names as bus descriptors. E.g.

I2C.create(“/dev/i2c-0”) returns an instance of I2C::Dev attached to the first I2c bus on the system.

Drivers¶ ↑

MCP23017¶ ↑

16 bit IO-Expander MCP23017 from Microchip. Provides a wiringpi-ruby compatible API and may therefore be used as a drop-in replacement for IO tasks on a Raspberry Pi. Datasheet: ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf

MCP23008¶ ↑

8 bit IO-Expander MCP23008 from Microchip. Basically a small version of the MCP23017. Datasheet: ww1.microchip.com/downloads/en/DeviceDoc/21919e.pdf

Acknowledgements¶ ↑

The low-level IO (mainly in i2c-dev.rb) was extracted from Ruby-I2C (rubyforge.org/projects/i2c/) by Jonas Bähr <jonas.baehr@fs.ei.tum.de>

Contributions¶ ↑

Bugfixes¶ ↑

  • Pierre Paques

Copyright / Licence¶ ↑

This code may be used under the terms of the GNU General Public Licence, Version 2.

Copyright © 2018 David Bailey <davidbailey.2889@gmail.com> Copyright © 2012 Christoph Anderegg <christoph@christoph-anderegg.ch> Copyright © 2008 Jonas Bähr <jonas.baehr@fs.ei.tum.de>