10

I'm just starting with Pi and want to program GPIO in Python. So far I've come across five libraries:

Before I commit time to learning one, I want to know:

  • If there are any limitations to one or the other.
  • What significant objective differences there are between them.
  • 2
    Oh ~duplicate raspberrypi.stackexchange.com/questions/27334/… – spinkus Dec 12 '16 at 7:41
  • You are correct, and this will probably be closed as subjective. There is no simple answer. gpiozero is a simple wrapper, designed for beginners. pigpio is probably the most powerful, although the documentation is sketchy, and more suitable to an experienced programmer. (I use wiringpi c because it is easier, but I have 40+ years c experience.) – Milliways Dec 12 '16 at 9:02
  • I suggest we close this question as opinion-based, unless we want every single person using GPIO to share their experience in the answers. – Dmitry Grigoryev Dec 12 '16 at 18:34
13

Warning. I am the author of pigpio so will be biased.

You might get a taste by looking at elinux.

RPi.GPIO was the first and is the most popular. It will be the one you most often see examples for.

RPIO builds upon RPi.GPIO (it is meant to be a plug in replacement) and adds some capabilities. In particular it adds hardware timed PWM suitable for LEDs and servos and hardware timed pulse chains. RPi.GPIO only provides software PWM which gives visible glitches in LEDs and is said to shorten the life of servos. As mentioned in RPIO github repo:

This repository is not actively maintained anymore!

wiringPi Python is a port of much of wiringPi's C functionality to Python. I haven't used it and don't know much about it.

pigpio Python is a port of pigpio's C functionality to Python. Like RPIO.GPIO it provides hardware timed PWM for LEDs and servos, and hardware timed pulse chains. One unique feature of pigpio is it times GPIO events at source so for any timing purpose pigpio is likely to be the most accurate. pigpio can run on a networked PC (Windows, Mac, Linux) to control a remote Pi.

gpiozero is a simplifying wrapper around pretty much any of the above libraries. It is in effect a front end which tries to remove the user as much as possible from the underlying implementation details. gpiozero (I think) is the Foundation recommended Python start point. gpiozero can (I think) run on a networked PC (Windows, Mac, Linux) to control a remote Pi if pigpio is the backend.

Warning, ask 10 other people and they will have 10 different views. All the libraries have their uses. They are all tools. Which is best for you depends on what sort of workman you are.

0

I would recommend RPi.GPIO but GPIO zero is best for beginners but has more limitations. However, I have no knowledge on the others but if I haven't heard of them it doesn't mean there not as good as the rest.

  • GPIO Zero does everything RPi.GPIO does, there are no limitations there. There are more advanced features in pigpio that aren't yet implemented in GPIO Zero, but for what it does support, it provides a nice API on top of either library. – ben_nuttall Apr 10 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.