rpi_i2c is a Dart package for using I2C on the Raspberry Pi.
Be sure to enable I2C on the Raspberry Pi using
RpiI2C uses a native library written in C. For security reasons, authors cannot publish binary content to pub.dartlang.org, so there are some extra steps necessary to compile the native library on the RPi before this package can be used. These two steps must be performed when you install and each time you upgrade the rpi_i2c package.
- Activate the rpi_i2c package using the pub global command.
pub global activate rpi_i2c
- From your application directory (the application that references the rpi_i2c package) run the following command to build the native library
pub global run rpi_i2c:build_lib
pub global activate makes the Dart scripts in the rpi_i2c/bin directory runnable from the command line. pub global run rpi_i2c:build_lib runs the rpi_i2c/bin/build_lib.dart program which in turn calls the build_lib script to compile the native librpi_i2c_ext.so library for the rpi_i2c package.
example.dart demonstrates instantiating and accessing an I2C device
example_ttp229.dart demonstrates instantiating and accessing the TTP229 touchpad over I2C
ttp229.dart demonstrates how the I2C API is used to interact with a
TTP229(See http://www.tontek.com.tw/uploads/product/106/TTP229-LSF_V1.0_EN.pdf) touchpad
It is recommended to attach two 4.7K pullup resistors, one to the SDA line and a second to the SDL line, althrough with some device boards already have pullup resistors on them. If you have many I2C devices and/or a long I2C bus, you many need a different value as per I2C pullup resistor recommendations.
|PIN #1 (3.3v)||3V||3V|
|PIN #3 (SDA1 / I2C)||SDA||SDA|
|PIN #3 (SDL1 / I2C)||SDL||SDL|
|PIN #6 (GND)||GND||GND|