Python libraries – pigpio

This is the third part of GPIO Python libraries series. Today I’m presenting pigpio C library with its Python client.

Pigpio

  • Author: joan2937
  • License: Unlicense?
  • PWM type: Software DMA
  • Available on PyPi: NO
  • Python 2 support: Yes
  • Python 3 support: Yes
  • Documentation: Average
  • Unit tests: NO
  • Source hosting: Github

Pigpio, similarly as described in previous post Wiring Pi, is a C library. It’s built from two parts, server and client. Server is written in C and there are two clients available: in C/C++ and in Python. What’s strange is that C client can only connect to localhost. Using Python client you can connect to any Pi in a network. This opens up some new possibilities.

I don’t know much about the author beside that he or she uses a nickname joan and is very active on the Raspberry Pi forum and on the stackexchange.com. It’s a very mysterious person.

To install the library follow the instructions one the Download page. Pigipio currently is not available on the PyPi. I will try to contact the author and offer the help in preparing the PyPi version. I hope that it will end as in the WiringPi case 🙂

Enough talking, let’s see the code. Before you start using pigpio Python client you need to start pigpio server:

Enabling/disabling LED

Reading button state

Rotating servo motor

LED brightness and DC motor speed

To control LED brightness or motor speed you can use the same code

Summary

Pigpio is my favorite library for now. It connects two worlds of C and Python and takes the best from both of them. PWM works perfectly, signal is very stable. When running servo motor I couldn’t see and vibrations.

Pigpio daemon has to run with root privileges but your program does not have this requirement which makes your application much much safer. It may or may not matter. It depends on you project. Client – server architecture allows you also to run your program on your computer which is awesome!

In the next week I will post a summary and this will finish my first series. See you later.

See the first part and the second part

Next ArticleNew PyPy release