Skip to content

Latest commit

 

History

History
36 lines (30 loc) · 1.6 KB

README.md

File metadata and controls

36 lines (30 loc) · 1.6 KB

I2C access for Haskell and Linux

I2C interface

This library provides a Haskell interface to I2C buses on Linux via /dev/i2c-[n]. It wraps the libi2c c-library, which is included as c-source, and works with every I2C interface that is supported by the Linux kernel.

Disclaimer

PCs and laptops use internal I2C buses to control various hardware functions. Incorrect use of the I2C interface can cause irreversible damage to your PC or laptop. Use this library with an external I2C interface (e.g. USB dongle) and double-check, that the /dev/i2c-[n] file belongs to that external interface.

Hardware

This library should work with every I2C interface that is supported by the Linux kernel. I test and use this library with an external I2C-Tiny-USB adapter. The I2C-Tiny-USB project consists of an AVR based hardware, an AVR firmware and a Linux kernel driver. The popular USBASP AVR programmers, that are available for ca $2, are compatible with I2C-Tiny-USB hardware. A firmware update is all that is needed to turn a USBASP AVR programmer into an I2C-Tiny-USB interface. (Note that the i2c_tiny_usb Linux kernel driver is broken in Linux 4.9 and Linux 4.11. But it works with this patch.

Examples

The library contains an example for reading barometer and compass data from an IMU (inertial measurement unit). Note that this example DOES NOT WORK unless you have the this specific IMU hardware device connected to your I2C bus.