Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Raspberry Pi slave library for Arduino

Version: 2.0.0
Release date: 2017 March 31


This is an Arduino library that helps establish I2C communication with a Raspberry Pi, with the Arduino acting as the I2C slave. It should work with most Arduino-compatible boards, but we designed it for use with these Pololu products:

These boards are designed to connect conveniently to the Pi's GPIO header. The idea is that the Raspberry Pi can take care of high-level tasks like video processing or network communication, while the AVR microcontroller takes care of actuator control, sensor inputs, and other low-level tasks that the Pi is incapable of.

There are a few reasons we made a library for this instead of just recommending the standard Arduino I2C library, Wire.h:

  • Wire.h just gives you access to raw I2C packets; you have to decide how they should relate to your data, and that's not trivial. This library implements a specific protocol allowing bidirectional access to a buffer, with atomic reads and writes.
  • The processor on the Raspberry Pi has a major bug that corrupts data except at very low speeds. The standard Arduino I2C library, Wire.h, is not flexible enough to allow us to follow the suggested workarounds (delays inserted at key points).

We have included example Arduino code for the A-Star or Romi and Python code for the Raspberry Pi. Together, the examples set up a web server on the Raspberry Pi that will let you remotely control and monitor a robot from your smartphone or computer.

Getting started

See this blog post for a complete tutorial including step-by-step build instructions for an example robot.


The included script times reads and writes of 8 bytes, to give you an idea of how quickly data can be transferred between the devices. Because of a limitation in the AVR's I2C module, we have slowed down reads significantly.

Bus speed Reads Writes
100 kHz 21 kbit/s 53 kbit/s
400 kHz 43 kbit/s 140 kbit/s

Version history

  • 2.0.0 (2017 Mar 31): Added support for encoder counts and slave sketch for the Romi 32U4 robot. Updated Raspberry Pi scripts to use Python 3 instead of Python 2.
  • 1.0.1 (2017 Jan 23): Added and adjusted delays necessary for reliable operation on the Pi 3.
  • 1.0.0 (2016 Feb 16): Original release.


An Arduino library that helps establish I2C communication between an A-Star 32U4 Robot Controller and a Raspberry Pi, with the Arduino acting as the I2C slave.







No packages published