joan2937/pigpio logo

joan2937/pigpio

Free

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

FreeFree tier
Type
Open Source

About joan2937/pigpio

pigpio is a C library for the Raspberry Pi that provides low-level control of General Purpose Input Outputs (GPIO). It supports high-speed sampling and time-stamping of GPIO 0-31 at rates up to 1,000,000 times per second, simultaneous PWM and servo pulse generation on any user GPIO, callbacks on state changes with microsecond accuracy, notifications via pipe, and timed callbacks. The library allows reading/writing all GPIO in a bank as a single operation, individual mode setting, and arbitrary waveform construction for precise output timing. Additional capabilities include software serial, I2C, and SPI over any user GPIO, rudimentary permission control, and script execution on the pigpiod daemon. Interfaces include C functions, a /dev/pigpio pipe, and a socket interface used by utilities such as pigpiod, pigs, piscope, pig2vcd, and a Python module.

Key Features

Sampling and time-stamping of GPIO 0-31 up to 1,000,000 times per second
Simultaneous PWM on any number of user GPIO
Simultaneous servo pulses on any number of user GPIO
Callbacks on GPIO state changes with microsecond-accurate timestamps
Notifications via pipe when any GPIO 0-31 change state
Callbacks at timed intervals
Reading/writing all GPIO in a bank (0-31 or 32-53) as a single operation
Individually setting GPIO modes, reading, and writing
Socket and pipe interfaces for most functionality
Construction of arbitrary waveforms with microsecond accuracy

Pros & Cons

Pros
  • High-speed sampling up to 1 MHz on GPIO 0-31
  • Simultaneous PWM and servo pulse generation on any user GPIO
  • Multiple interface options: C, Python, socket, pipe
  • Microsecond-accurate callbacks and waveform construction
  • Comprehensive set of utilities: daemon, command-line, waveform viewer
  • Open source with active community support
Cons
  • Limited to Raspberry Pi hardware only
  • Requires C programming knowledge for full flexibility
  • No high-level abstraction – direct GPIO manipulation
  • GPIO availability varies by Raspberry Pi board revision

Best For

High-speed GPIO sampling for sensor reading or signal analysisControlling multiple PWM devices (e.g., LEDs, motors) simultaneouslyGenerating precise servo control signals for robotics or automationImplementing custom serial protocols (serial, I2C, SPI) on any GPIOWaveform generation for timing-critical output sequencesBuilding logic analyzers or digital waveform viewers with piscope