
Say hello to the GPIO
The GPIO connector is the large group of pins on the edge of your Raspberry Pi board. On earlier models, there were 26 pins that made up this connector. But, ever since the Model B+, there have been 40 pins, although the first 26 pins are identical to the previous models, and it's these 26 pins we'll be working with. You won't need to worry about the rest of the pins.
Essentially, the GPIO connector provides access to following:
- Power supplies
- Digital I/O pins
- I2C bus
- SPI bus
- UART Serial bus
Some of the pins on the GPIO have more than one purpose, depending on how they are programmed. The following diagram is a reference guide to all of the pins on the GPIO. The GPIO numbers on the yellow labels relate directly to those on the Broadcom chip, and are numbers generally used within the scripts.

Digital I/O pins
The GPIO has 8 digital input/output pins available for use. These can be used to switch things on and off (in output mode), and also to detect when external things are switched on and off (input mode). Each pin can be configured independently for input or output operation, and I have labelled them D0 to D7 in the preceding diagram.
Obviously, if we were to use each of these pins to drive or sense an individual device, we would be limited to a maximum of 8 devices that could be connected to our home security system. In many scenarios, this is probably not enough, so in the next chapter we'll learn how to use the GPIO to connect many more things to our Raspberry Pi.
The I2C bus
The Inter-Integrated Circuit (I2C) bus is a low-speed interface that can connect multiple devices and simple sensors using a 2-wire interface without the need for a separate clock or device select line. Typically, this bus can operate at speeds up to 100kbit/s. We'll be covering this in the next chapter to help us expand our digital I/O and connect more things.
The SPI bus
The Serial Peripheral Interface (SPI) bus is a synchronous two-way serial connection between a master and a slave device. It can be used to access more complex sensors or drive displays.
The master device provides the synchronization, and each transmission is synchronized by a clock pulse on SCLK (GPIO11/pin 23). Data is transmitted on the MOSI (master-out-slave-in) and MISO (master-in-slave-out) (pins 19 and 21 respectively).
The UART serial bus
The Universal Asynchronous Receiver and Transmitter (UART) bus is a way to communicate with external devices over a serial data connection, and is a common way for the Raspberry Pi to access data from devices such as GPS modules, which often come with serial connections. It can be a little bit fiddly getting the Pi set up to communicate with UART-connected devices, as it's also tied in with the operating system's serial console.
USB ports
We're probably all familiar with Universal Serial Bus (USB) ports as we use them to connect all sorts of things to our PCs, such as keyboards, mouses, and hard disks. On the Raspberry Pi, it's just the same; we can connect keyboards, mouses, and dongles to give us Wi-Fi and Bluetooth connectivity.

Official Raspberry Pi USB Wi-Fi Dongle
On earlier Raspberry Pi models, the amount of current that the ports delivered was pretty low and caused all sorts of problems if too much current was drawn by the connected devices. This was significantly improved from the model B+ onwards, and it's now possible to connect GSM/LTE dongles without any problems.
There are still limitations, however, if you want to connect things such as hard disk drives; these can still draw more current than what can be supplied by the Raspberry Pi USB ports, so it's recommended that a powered USB hub or USB power injector be used when connecting these types of devices to your Pi.
Power connections
The GPIO connector also provides access to the on-board power supplies. The +5V connection (pins 2 and 4) is essentially the +5V input from the external power supply connected to the micro-USB power port. This can be used to power small external circuits if necessary, although it is recommended that an additional external +5V supply be used if significant current is required.
The +3.3V supply (pins 1 and 17) is the output from the on-board 3.3V regulator and provides a small amount of current up to 50mA. If you need to draw more than 50mA for your external circuits, then you should use an external power supply. I'll show you how to build one later in this book.
Note
The I/O pins on the Raspberry Pi operate at 3.3V levels. Connecting voltages higher than this to the pins could irreversibly damage your Pi. If you follow the instructions in this book, then everything should be fine, but randomly connecting things to your Pi that use lots of power will break it!