rpi_i2c 0.1.0

  • README.md
  • Example
  • Installing
  • Versions
  • new50


pub package Build Status Coverage Status

rpi_i2c is a Dart package for using I2C on the Raspberry Pi.


  • The I2C library provides the API for accessing devices using the I2C protocol

  • 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

    sudo raspi-config

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.

  1. Activate the rpi_i2c package using the pub global command.
    pub global activate rpi_i2c
  1. 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.




  • Initial implementation


import 'dart:async';

import 'package:rpi_i2c/rpi_i2c.dart';

import 'mpl3115a2.dart';

main() async {
  await readSensor(new Mpl3115a2(new RpiI2C()));

Future readSensor(Mpl3115a2 mpl3115a2) async {
  Mpl3115a2Data result;

  print('Pressure and temperature:');
  result = await mpl3115a2.read();
  print('  pressure: ${result.pressure} pascals');
  print('  temperature: ${result.temperature} celsius');

  print('Altitude and temperature:');
  result = await mpl3115a2.read(altitude: true);
  print('  altitude: ${result.altitude} meters');
  print('  temperature: ${result.temperature} celsius');

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  rpi_i2c: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:rpi_i2c/rpi_i2c.dart';
Version Uploaded Documentation Archive
0.1.0 Sep 14, 2018 Go to the documentation of rpi_i2c 0.1.0 Download rpi_i2c 0.1.0 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Sep 18, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.3


Detected platforms: other

Primary library: package:rpi_i2c/rpi_i2c.dart with components: nativewrappers.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.60.0 <3.0.0
path >=1.0.0 <2.0.0 1.6.2
Dev dependencies
grinder ^0.8.0
test ^1.2.0