14

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.
spinkus
  • 311
  • 2
  • 3
  • 8
  • 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 09: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

2 Answers2

19

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.

joan
  • 71,024
  • 5
  • 73
  • 106
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.

King Balloonion
  • 173
  • 1
  • 2
  • 14
  • 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 '19 at 13:34