pigpio is a C library for the Raspberry which allows control of the General Purpose Input Outputs (GPIO).
C Groff Python Objective-C Shell C++ Other
Latest commit 4862a16 Jan 11, 2017 @joan2937 committed on GitHub Update README.md
Permalink
Failed to load latest commit information.
EXAMPLES pep8:E711 comparison to None should be `if cond is not None:` Apr 27, 2016
util Merge branch 'master' of https://github.com/fudger/pigpio. Mar 12, 2016
.gitignore Add dist, *pyc and .egg-info to .gitignore Dec 21, 2016
MakeRemote V43 Dec 31, 2015
Makefile Add CROSS_PREFIX var to make cross-compilation easier Oct 30, 2016
README V40 Nov 10, 2015
README.md Update README.md Jan 11, 2017
UNLICENCE V6 Dec 12, 2013
command.c V57 Oct 30, 2016
command.h V57 Oct 30, 2016
custom.cext V26 Feb 2, 2015
pig2vcd.1 V55 Jul 10, 2016
pig2vcd.c V6 Dec 12, 2013
pigpio.3 V58 Nov 3, 2016
pigpio.c V60 Jan 10, 2017
pigpio.h V60 Jan 10, 2017
pigpio.py V59 Dec 22, 2016
pigpiod.1 V58 Nov 3, 2016
pigpiod.c V58 Nov 3, 2016
pigpiod_if.3 V57 Oct 30, 2016
pigpiod_if.c V55 Jul 10, 2016
pigpiod_if.h V57 Oct 30, 2016
pigpiod_if2.3 V59 Dec 22, 2016
pigpiod_if2.c V57 Oct 30, 2016
pigpiod_if2.h V59 Dec 22, 2016
pigs.1 V57 Oct 30, 2016
pigs.c V57 Oct 30, 2016
setup.py V60 Jan 10, 2017
x_pigpio.c V48 Mar 8, 2016
x_pigpio.py V48 Mar 8, 2016
x_pigpiod_if.c V48 Mar 8, 2016
x_pigpiod_if2.c V48 Mar 8, 2016
x_pigs V57 Oct 30, 2016
x_pipe V48 Mar 8, 2016

README.md

pigpio

pigpio is a C library for the Raspberry which allows control of the General Purpose Input Outputs (GPIO).

Features

sampling and time-stamping of GPIO 0-31 between 100,000 and 1,000,000 times per second.

provision of PWM on any number of the user GPIO simultaneously.

provision of servo pulses on any number of the user GPIO simultaneously.

callbacks when any of GPIO 0-31 change state (callbacks receive the time of the event
accurate to a few microseconds).

notifications via pipe when any of GPIO 0-31 change state.

callbacks at timed intervals.

reading/writing all of the GPIO in a bank (0-31, 32-53) as a single operation.

individually setting GPIO modes, reading and writing.

socket and pipe interfaces for the bulk of the functionality in addition to the
underlying C library calls.

the construction of arbitrary waveforms to give precise timing of output GPIO
level changes (accurate to a few microseconds).

software serial links, I2C, and SPI using any user GPIO.

rudimentary permission control through the socket and pipe interfaces so users
can be prevented from "updating" inappropriate GPIO.

creating and running scripts on the pigpio daemon.

Interfaces

The library provides a number of control interfaces

the C function interface

the /dev/pigpio pipe interface

the socket interface (used by the pigs utility and the Python module)

Utilities

A number of utility programs are provided

the pigpiod daemon.
the Python module.
the piscope digital waveform viewer.
the pigs command line utility.
the pig2vcd utility which converts notifications into the value change dump (VCD)
format (useful for viewing digital waveforms with GTKWave).

Example programs

See http://abyz.co.uk/rpi/pigpio/examples.html

GPIO

ALL GPIO are identified by their Broadcom number. See elinux.org

There are 54 GPIO in total, arranged in two banks.

Bank 1 contains GPIO 0-31. Bank 2 contains GPIO 32-54.

A user should only manipulate GPIO in bank 1.

There are at least three types of board.

Type 1

26 pin header (P1).

Hardware revision numbers of 2 and 3.

User GPIO 0-1, 4, 7-11, 14-15, 17-18, 21-25.

Type 2

26 pin header (P1) and an additional 8 pin header (P5).

Hardware revision numbers of 4, 5, 6, and 15.

User GPIO 2-4, 7-11, 14-15, 17-18, 22-25, 27-31.

Type 3

40 pin expansion header (J8).

Hardware revision numbers of 16 or greater.

User GPIO 2-27 (0 and 1 are reserved).

It is safe to read all the GPIO. If you try to write a system GPIO or change its mode you can crash the Pi or corrupt the data on the SD card.