RETIRED - Pi Wedge Hookup Guide

This Tutorial is Retired!

This tutorial covers concepts or technologies that are no longer current. It's still here for you to read and enjoy, but may not be as useful as our newest tutorials.

View the updated tutorial: RETIRED - Pi Wedge B+ Hookup Guide

Pages
Contributors: Byron J.
Favorited Favorite 3

Software

With the many programming languages available on the Pi, it's hard to know where to start writing software that interfaces with the I/O connector.

As a quick and easy way to check out the connections on the IO connector, check out the WiringPi package. Wiring Pi is a hardware interface library that includes a utility to help you configure and check the status of the GPIO connector pins.

Follow these instructions to install Wiring Pi.

Once you've got it installed, you can use the gpio command line utility to quickly check and test hardware connections.

gpio takes a number of arguments. The readall option prints a handy table that deciphers the configuration and assignment of the pins. It also detects the revision of the Pi, and translates the pin numbers to match.

user@raspberrypi:~/wedgetest$ gpio readall
+----------+-Rev2-+------+--------+------+-------+
| wiringPi | GPIO | Phys | Name   | Mode | Value |
+----------+------+------+--------+------+-------+
|      0   |  17  |  11  | GPIO 0 | IN   | Low   |
|      1   |  18  |  12  | GPIO 1 | IN   | Low   |
|      2   |  27  |  13  | GPIO 2 | IN   | Low   |
|      3   |  22  |  15  | GPIO 3 | IN   | Low   |
|      4   |  23  |  16  | GPIO 4 | IN   | Low   |
|      5   |  24  |  18  | GPIO 5 | IN   | Low   |
|      6   |  25  |  22  | GPIO 6 | IN   | Low   |
|      7   |   4  |   7  | GPIO 7 | IN   | Low   |
|      8   |   2  |   3  | SDA    | IN   | High  |
|      9   |   3  |   5  | SCL    | IN   | High  |
|     10   |   8  |  24  | CE0    | IN   | Low   |
|     11   |   7  |  26  | CE1    | IN   | Low   |
|     12   |  10  |  19  | MOSI   | IN   | Low   |
|     13   |   9  |  21  | MISO   | IN   | Low   |
|     14   |  11  |  23  | SCLK   | IN   | Low   |
|     15   |  14  |   8  | TxD    | ALT0 | High  |
|     16   |  15  |  10  | RxD    | ALT0 | High  |
|     17   |  28  |   3  | GPIO 8 | ALT2 | Low   |
|     18   |  29  |   4  | GPIO 9 | ALT2 | Low   |
|     19   |  30  |   5  | GPIO10 | ALT2 | Low   |
|     20   |  31  |   6  | GPIO11 | ALT2 | Low   |
+----------+------+------+--------+------+-------+

Somewhat confusingly, you'll notice that the first 3 columns of that table are all different numbers, each a different way to refer to the pins on the Pi. The "wiringPi" column is a set of contiguous numbers that WiringPi uses by default. The "GPIO" comumn uses the GPIO channel numbers as assigned within the BCM2835 processor. The "phys" column corresponds to the pin number of the P1 connector on the Pi.

The Pi Wedge is labeled with the numbers seen in the GPIO column.

If you run gpio without any parameters, it displays the available options. You can use it to configure, read and write pins right from the command line. Similarly, man gpio displays more detailed information on using the utility, including a number of sample commands.

Programming

If you're coming from Arduino, and you've got a handle on how it manages I/O, you'll find that the WiringPi libraries present a familiar programming interface. We have a few WiringPi based examples in the Pi Wedge GitHub Repository that should help you get started.

If Python is more your speed, then take a look at the RPi.GPIO module.

For more detailed information about using both WiringPi and RPi.GPIO, take a look at our Raspberry gPIo tutorial.