Vous êtes sur la page 1sur 5

Download and Install

WiringPi is now maintained under GIT for ease of change tracking, however there is a Plan B if
youre unable to use GIT for whatever reasons (usually your firewall will be blocking you, so do
check that first!)

If you do not have GIT installed, then under any of the Debian releases (e.g. Raspbian), you can
install it with:

sudo apt-get install git-core

If you get any errors here, make sure your Pi is up to date with the latest versions of Raspbian:

sudo apt-get update


sudo apt-get upgrade

To obtain WiringPi using GIT:

git clone git://git.drogon.net/wiringPi

If you have already used the clone operation for the first time, then

cd wiringPi
git pull origin

Will fetch an updated version then you can re-run the build script below.

To build/install there is a new simplified script:

cd wiringPi
./build

The new build script will compile and install it all for you it does use the sudo command at one
point, so you may wish to inspect the script before running it.

Plan B

Click on this URL: (it should open in a new page)

https://git.drogon.net/?p=wiringPi;a=summary

Then look for the link marked snapshot at the right-hand side. You want to click on the top one.
This will download a tar.gz file with a name like wiringPi-98bcb20.tar.gz. Note that the numbers
and letters after wiringPi (98bcb20 in this case) will probably be different theyre a unique
identifier for each release.

You then need to do this to install:

tar xfz wiringPi-98bcb20.tar.gz


cd wiringPi-98bcb20
./build

Remmeber the actual filename will be different you will have to check the name and adjust
accordingly.

Test wiringPis installation

run the gpio command to check the installation:

gpio -v
gpio readall

That should give you some confidence that its working OK.

WiringPi is released under the GNU Lesser Public License version 3.

How to install WiringPi2 for Python on the


Raspberry Pi
Add comments

WiringPi2 for Python installation instructions for Raspbian

What is WiringPi2 and why do I need it?

WiringPi2 for Python is an excellent GPIO handling system written by Gordon Drogon
Henderson and packaged for Python by Phil Gadgetoid Howard. It uses Arduino-like scripting
language. For simple GPIO work, I use RPi.GPIO because thats what I first got started with.
But, aside from hardware PWM, one thing I love about WiringPi2 is that it also has some extra
built-in drivers for various chips e.g. the MCP23x17 & x8 port expanders. This makes handling
expanded ports as easy as

1. defining a pin
2. setting it as input or output
3. reading or writing to the pin

All the low level heavy lifting is done for us. :) Youve still got to hook up your own wires
though. I think Gordons working on that for V3 :p

Installing WiringPi2 for Python

Installing WiringPi2 for Python is very simple, but there are a couple of required packages, so
well install those first. Before we install anything, though, lets update the package lists

sudo apt-get update


This is what should happen

Update Raspbian package lists


Now we need the following. If theyre already installed, no harm will be done
sudo apt-get install python-dev python-pip

If asked, confirm that you want to go ahead with the installation with y

install python-pip & python-dev

This will take several minutes. When its finished, you should see this

Dependencies installed

Now were ready to install WiringPi2 for Python itself


sudo pip install wiringpi2

You will see lots of messages. pip, the python package installer that you just installed, is
compiling WiringPi2 and installing it all for you. After lots of messages starting with gcc
pthread, you should see this
WiringPi2 installed :)

Lets check it

Now you should be good to go. Lets check that it works with a live Python environment

sudo python
import wiringpi2
wiringpi2.piBoardRev()

Checking WiringPi2 python works

We just imported wiringpi2 and used one of its new functions piBoardRev() which is the built-in
Raspberry Pi revision checker. Notice it returned a 2, which is good because Im using a Rev 2
board. ;) If that all works as it should

ctrl+d to exit python

You are installed and ready for action with WiringPi2s GPIO features.

I will be creating a page for simple WiringPi2 usage instructions in the near future.

Vous aimerez peut-être aussi