rpi_i2c is a Dart package for using I2C on the Raspberry Pi.
The RpiI2C library provides implementation of the I2C protocol on the Raspberry Pi derived from the WiringPi library.
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_native
pub global activate makes the Dart scripts in the rpi_i2c/bin directory runnable from the command line. pub global run rpi_i2c:build_native runs the rpi_i2c/bin/build_native.dart program which in turn calls the build_native script to compile the native librpi_i2c_ext.so library for the rpi_i2c package.
|example.dart||instantiating and accessing an I2C device|
|mpl3115a2.dart||Mpl3115a2 pressure sensor with altimetry|
|ttp229.dart||TTP229 I2C touchpad|
|tsl2561.dart||TSL2651 light sensor which is embedded in the Grove Light Sensor v1.1|
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.
|Rpi Pin||MPL3115A2||TTP229||Pull-up Resistors|
|PIN #1 (3.3v)||3V||3V|
|PIN #3 (SDA1 / I2C)||SDA||SDA||4.7K resistor to 3.3V|
|PIN #5 (SDL1 / I2C)||SDL||SDL||4.7K resistor to 3.3V|
|PIN #6 (GND)||GND||GND|