Introduction

Pingo provides a uniform API to program devices like the Raspberry Pi, pcDuino, Intel Galileo etc. just like the Python DBAPI provides an uniform API for database programming in Python.

The API is object-oriented but easy to use: each board is an instance of a Board subclass. Every board has a dictionary called pins which lists all GPIO pins on the board. Each pin is an instance of a Pin subclass with attributes that you can inspect to learn about its capabilities.

A single script can easily control more than board at the same time. For example, a program running on the pcDuino can control the pcDuino itself and two Arduinos connected to the pcDuino via USB using the Firmata protocol.

The name Pingo is a tribute to Garoa Hacker Clube, where the project started (in Portuguese, “pingo” is drop and “garoa” is drizzle). To our English-speaking friends we like to say Pingo means: “pin, go!” – this nicely sums up the purpose of this package.

Basic usage

To use pingo, the first step is to instantiate a Board. Each Pingo driver is a concrete board subclass, for example, pingo.rpi.RaspberryPi and pingo.arduino.ArduinoFirmata are two such classes.

Pingo can automatically detect the board in most common cases. If the script is running on a supported board, pingo.detect.MyBoard() returns an suitable board instance. If Pingo is running on an unsupported machine (eg. a notebook), it will try to find a connected Arduino using the Firmata protocol via USB and – if successful – will return a pingo.arduino.ArduinoFirmata instance.

Once you have a board instance, it’s possible to access its pins through the board.pins dictionary:

import pingo
from time import sleep

board = pingo.detect.MyBoard()
led_pin = board.pins[13]
led_pin.mode = pingo.OUT

while True:
    led_pin.hi()
    sleep(1)
    led_pin.lo()
    sleep(1)

Drivers

pingo.pcduini.PcDuino pingo.galileo.Galileo2 are examples of drivers, and the respective PcDuino and Galileo2 are subclasses of the pingo.board.Board abstract class that defines the common API for all boards.

The following table lists the drivers currently planned or under development.

Board Type Module/Package Status Notes
Arduino Firmata remote arduino.firmata level 1 requires firmata protocol on any Arduino board
Arduino Yún on-board arduino.yun level 2 requires Bridge sketch on the Arduino Yún
BeagleBone Black on-board bbb experim.  
Intel Galileo Gen 2 on-board galileo level 2 requires Intel IoT Dev Kit mraa library
LinkSprite pcDuino on-board pcduino level 1  
RaspberryPi on-board rpi level 0 requires RPi.GPIO on the Raspberry Pi
SECO UDOO on-board udoo level 0  

We are also interested in supporting: Banana Pi, Cubietech Cubieboard, SolidRun HummingBoard, TI MSP430 (via firmata protocol ).

In a addition, Pingo implements ghost, a mock software-only board for testing the API.

Types of drivers

on-board
Pingo and user code run on the board itself, using the Python interpreter installed in it.
remote
Pingo and user code run on host computer connected to board, controlling the board remotely. Useful for boards that are unable to run Python, like the Arduino UNO.
fake
Pingo and user code run on host computer emulating a dummy board in software. Useful for testing base classes from board.py and for teaching and demonstration.

Status of drivers

level 0
Digital I/O: get/set high/low status of digital pins (no PWM support).
level 1
Analog input: read values from analog pins.
level 2
PWM output: set variable value for digital pins with PWM capability.
experiments
Some Python experiments have been done with the board. See the experiments/ directory for code that may be helpful to start a new driver for a board.
none
Nothing has been done. Great opportunity for you to contribute with experiments and/or start a new driver.

Installation

There are two ways of installing Pingo:

  1. from Python PyPI
  2. from Github (recommended)

Installing from PyPI

To install Pingo from PyPI (Python Package Index), first, make sure you have pip installed in your machine. On Linux machines, this usually means you have the python-pip package installed. You can check if you have pip in your machine by typing the following text on a shell prompt:

$ pip --version
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)

If the output is similar from the one above, you can install Pingo by simple typing pip install pingo as root on you terminal. That’s it!

Installing from Github

Since Pingo is currently in alpha state and under heavy develpment, installing Pingo from Github may be a good idea. Besides that, it will be easy for you to contribute to the project, if you wish. See the Contributing section on the left menu.

To install Pingo from Github, you must have Git installed. Presuming you already have that, just type:

$ git clone https://github.com/pingo-io/pingo-py.git

After that, get into the pingo directory and setup Python to use your brand new directory as a library:

$ python setup.py develop

Done! You are ready to program using Pingo!