Skip to content
epsilonrt edited this page Jan 11, 2020 · 14 revisions

Arduino on Pi boards, the best of both worlds


PiDuino is a C++ library for Pi boards that allows the use of I/O like GPIO, I2C, SPI, UART ... with an API as close as possible to the Arduino language.
The description of Pi cards uses a stored "Object" model in a database that allows to add new models of boards easily.

At this time, the SoC models supported are AllWinner H-Series and Broadcom BCM2708 through 2710 which allows it to be used on Raspberry Pi, most Nano Pi, Orange Pi and Banana Pi.

Genesis of the project

PiDuino was born from a question from one of my students who asked me why programming input-output on NanoPi was not as simple as on Arduino.

PiDuino therefore aims to respond to this need:

An Application Programming Interface (API) on Pi boards as close as possible to that of Arduino.

This API must allow to use GPIO, Serial port, I2C bus and SPI... on Raspberry Pi, Nano Pi,Orange Pi, Banana Pi, Beagle Board... boards as on an Arduino board.

What PiDuino offers:

  • A programming interface API same as Arduino except adding #include <Piduino.h>at the beginning of the program. It does not prohibit offering extensions of the API but provided that stay as independent as possible from the platform and not to make the code incompatible with Arduino. It makes sense to think that users who want to stay in the Arduino world use C ++, PiDuino is intended for this use case. Nevertheless some functions can be used in C (pinMode (), digitalWrite (), ...).

  • The description of Pi boards that is based on an "Object" model stored in a database (SQLite by default), allowing a simple user to add a new Pi board "variant" WITHOUT programming.

  • An object design in C++ with a clear separation of the part specific to the platform. Support for new SoCs is summarizes to add a part "driver" in the directory src/arch

  • Utilities for manipulating GPIO signals: pido, retrieve information from the board: pinfo or manage the Pi boards database: pidbman


There are some projects that have sought to meet this need but only to propose a solution for a Pi card model.

The best known is probably wiringPi. wiringPi is a solution planned for Raspberry Pi and even though it there are derivative versions on other Pi boards, these versions are "lame" versions from a software engineering point of view of the original version.

These are the reasons that led me not to choose wiringPi:

  • Even if there is a similarity with Arduino programming, there is has differences that increase with time.
  • wiringPi was designed in pure C, which is a definite brake on scalability and is not very consistent with Arduino (The Arduino language is C++ !)
  • wiringPi was designed for the Raspberry Pi and its adaptation for other Pi boards is increasingly unthinkable, as and when of the arrival of new Pi boards. Just go to the ArmBian website to see the multitude of Pi models !

Project status

PiDuino is in development, version 0.5 currently but the completed parts are functional on Broadcom SoC BCM283X and AllWinner Hx.