Python libraries – Wiring Pi

This is the second part of GPIO Python libraries series. Today I would like to introduce a Wiring Pi 2 library which has its origins in Arduino world.

Wiring Pi 2 summary

  • Author: Gordon Henderson
  • Author: Philip Howard
  • License: LGPL
  • PWM type: Software
  • Available on PyPi: NO YES
  • Python 2 support: Yes
  • Python 3 support: Yes
  • Documentation: Poor
  • Unit tests: NO
  • Source hosting: Github

Wiring Pi is a C library which has a Python bindings and this post is about Python version. It’s designed to be familiar for people who have used Arduino “wiring” system. Gordon Henderson is an author of C library and Philip Howard is an author of bindings. There are two major versions of this library: 1 and 2. I will focus only on version 2 here. 

According to PyPi ranking, Wiring Pi is the third library on the PyPi. But it says nothing to us. Version on PyPi is almost 2 years old, so if you want to get the latest version you need to go to Github and install it manually. I tried to contact Philip but he didn’t answer me and I don’t know why he stopped uploading new versions to PyPi. (Update 11 march 2015, Philip Howard uploaded newest version of Wiring Pi 2 to PyPi. You can install it by running: pip install wiringpi2)

Now let’s see the code. I’m using the same examples as in part one:

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

Wiring Pi is a little harder to use than RPi.GPIO. There is no PyPi version (Update: wiringpi2 is on PyPi now) and there are no system packages. You need to install it manually which may cause some problems for beginners.
Wiring Pi likes to silently ignore errors. If you don’t initialize it with for example wiringpi.wiringPiSetupGpio() and try to set pin as output it will not fail. You will not get any error but nothing will happen. It’s hard to debug such libraries.

Wiring Pi has one killer future which I will describe in another post. It has support for a LCD screens, for the PiGlow, for the PiFace and for the Gertboard. You can use them out of the box!

Wiring Pi, like RPi.GPIO, uses a software PWM. This time it looks little better, signal seems to be more stable.

That is all for today. On the next Tuesday I will show pigpio library.

See the first part.

  • Pingback: Python libraries – pigpio |()

  • Mehmet Asım

    Hi, can we create more than one pwm output pins simultaneously by using this library? or do we use only one pwm output ?

    • Hey, I’ve never tried it with this library but I think it should work.

Next ArticlePython libraries – pigpio