Raspberry Pi Pinout?

The Raspberry Pi is a series of small, affordable single-board computers that have become very popular for DIY electronics projects. At the heart of every Raspberry Pi is the Broadcom system-on-a-chip (SoC) which integrates the central processing unit (CPU), graphics processing unit (GPU), and memory. To connect external devices and accessories, the Raspberry Pi has several pin headers that provide access to the input/output features of the SoC. Learning the pinout and function of each pin is key to properly interfacing sensors, displays, motors, and other components to create Raspberry Pi projects.

Raspberry Pi Pinout?

There have been several generations of Raspberry Pi boards over the years. The original Model A and Model B boards were followed by the Model A+, B+, 2B, 3B, 3A+, 3B+, 4B and most recently, the Raspberry Pi 400 keyboard computer and Pi Pico microcontroller board. While each new model brings improvements to factors like processor speed, memory capacity, connectivity options and form factor, the pin headers to access device input/output have remained largely consistent.

Every Raspberry Pi board, with the exception of Pi Pico, features several rows of pins along the edges and operates with 3.3V logic levels. The main pin header is the 40-pin General Purpose Input/Output (GPIO) header which provides access to the core device functions. There is also often a second, smaller 13- or 15-pin header dedicated to video out signals. Additionally, boards may have 4- or 5-pin headers for functions like serial console access or cameras.

GPIO Pinout Diagram

The diagrams below illustrate the GPIO pinout and layout for the most common 40-pin header found on full-size Raspberry Pi boards like the 3B+ and 4B:

[[Image for GPIO diagram]]

The first 26 pins are related to general purpose digital input and output (GPIO). Pins 27 and 28 provide 3.3V power and ground pins. Pins 29-40 provide various hardware interfaces and alternate functions described in more detail in the next section.

You’ll notice that there are two different numbering systems used – the physical pin number (1-40) and the Broadcom GPIO number used in software (GPIO2, GPIO27, etc). It’s important to pay attention to which numbering scheme is expected when configuring a pin’s mode or reading/writing data.

GPIO Pin Functions and Alternate Uses

While called the “General Purpose Input/Output” header, not all pins are created equal. Some pins have dedicated special functions or alternate uses that are important to understand before wiring up your Raspberry Pi project.

Power Pins

  • Pins 1 and 17 – 3.3V power
  • Pins 2, 4 and 35-39 – 5V power
  • Pins 6, 9, 14, 20, 25, 30, 34, 39 – Ground

The 3.3V and 5V power pins can be used to supply a moderate amount of current to other devices or components like LEDs, motors, sensors, etc. Avoid drawing more than 50mA from any individual GPIO. For higher current devices, you’ll need an external power supply.

I2C Interface

  • Pin 3 – SDA (data line)
  • Pin 5 – SCL (clock line)

The I2C interface provides serial communication capability using just two pins which is convenient for connecting low-speed peripheral ICs and sensors. Devices share the bus and each is addressable via software.

UART Hardware Serial Port

  • Pin 8 – TXD (transmit)
  • Pin 10 – RXD (receive)

This provides full-duplex serial communication compatible with RS232 serial ports. Often used with serial displays, modems, some sensors, etc.

SPI Interface

  • Pin 19 – MOSI
  • Pin 21 – MISO
  • Pin 23 – SCLK
  • Pin 24 – CE0
  • Pin 26 – CE1

The SPI interface allows high-speed synchronous full duplex communication with external devices. Chips share clock (SCLK) and data in/out lines with individual slave select (CE) signals. Often used for display drivers, flash memory, A/D converters, etc.

PWM and Analog

  • Pin 12 – PWM0
  • Pin 13 – PWM1
  • Pin 18 – PCM_CLK
  • Pin 22 – PCM_FS
  • Pin 32 – PWM0
  • Pin 33 – PWM1
  • Pin 35 – ADC0
  • Pin 36 – ADC1
  • Pin 37 – ADC2
  • Pin 38 – ADC3

Pulse Width Modulation (PWM) output is available on some pins which allows generating analog voltages to control motors, LED brightness, etc. The PCM pins can configure digital audio output. ADC provides analog input capability.

Miscellaneous Interfaces

  • Pin 15 – GPIO_GEN0
  • Pin 16 – GPIO_GEN1
  • Pin 27 – ID_SC
  • Pin 28 – ID_SD

The programmable generic GPIO 0 and 1 signals can trigger interrupts. The ID EEPROM pins enable auto-detection of different Pi models. There are also HDMI and camera ports and display signals routed to pins of the video out header.

Key Takeaways

The most important facts about the Raspberry Pi GPIO pinout are:

  • Pin functions may be different than physical pin numbers
  • Pay attention to Broadcom GPIO vs physical pin numbers
  • All pins operate at 3.3V logic levels
  • Check voltage and current limits before connecting devices/sensors
  • Use 3.3V or GND pins to supply moderate power to components
  • I2C, SPI, UART provide serial communication interfaces
  • PWM capable pins allow analog voltage control
  • Some signals have dedicated or alternate functions

Wiring and Using the GPIO Pins Safely

The Raspberry Pi’s GPIO pins provide incredible flexibility, but care must be taken to avoid device damage or malfunction. Here are some key wiring safety tips:

  • Double check signals – 5V can damage 3.3V logic!
  • Cable insert direction often matters – pay attention to diagrams
  • Avoid short circuits – use jumper wires/breadboards designed for protoyping
  • Static discharge can impact exposed SoC pins
  • Ensure power demands of connected devices are within limits
  • Use a logic level converter when interfacing 5V devices
  • Prototype initial designs before soldering finished projects

Start with the ample prototyping capabilities of jumper wires, breadboards and simple components like buttons and LEDs. As experience is gained, more complex sensors, motors and displays can be added. Taking deliberate steps will ensure you don’t let the magic smoke out of your Pi!

Example Circuits and Projects

The variety of hardware interfaces available via the GPIO pins enables no end of possibilities – smart homes, gaming controllers, IoT devices, robots and more. Here are just a few project ideas:

LED Blink Circuit

The “Hello World” of physical computing – blink an LED using a simple Python script! Uses digital IO, PWM for brightness control and a current limiting resistor. Great way to learn GPIO control.

[[Simple circuit diagram with LED, resistor and pin to ground]]

Environment Sensor Station

Connect analog / digital temperature, humidity, pressure and light sensors then log data to file or upload to a weather service. Add tiny LCD display or LED indicators. Runs stand-alone once scripted.

Interactive Game Controller

Retro arcade emulator console with customized controller using buttons and a joystick connected to GPIO pins. Maps custom inputs to keyboard presses for gaming.

Internet Radio Player

Streaming MP3 player pulling tunes from the cloud. Integrate speaker driver board, rotary encoder volume control and OLED playlist display. Tune in stations from anywhere and listen away!

Home Automation Hub

Central controller for lights, appliance plugs, sensors and security cameras. Could interface with Alexa/Google Assistant for voice control. Web server provides mobile access and automation rules processing.

Final Thoughts

With minimal components, a Raspberry Pi provides a full-featured development board for electronics experimentation and learning. The GPIO header exposes the core input and output capabilities of the SoC providing avenues to interface all kinds of devices and accessories. An understanding of the pinout and functions combined with basic programming empowers endless projects at home or in the classroom.

As single board computers continue to evolve with faster processors, connectivity options and form factors, the Raspberry Pi foundation’s commitment to simple, affordable and accessible technology serves as an inspiration. So grab your Pi and jumper wires and let your imagination guide your creations! The world of physical computing awaits…

Frequently Asked Questions

  1. What is the difference between the numbers on the pin diagram vs Broadcom GPIO numbers?
    The physical pin numbers from 1-40 identify the actual pins along the header rows while the Broadcom numbers refer to specific ports and functions within the SoC itself used when programming.

  2. Can I connect components running at 5 volts directly?
    No! Raspberry Pi GPIO pins work exclusively at 3.3V levels. Higher voltages can permanently damage pins. Use a logic level converter when necessary.

  3. How much total current across all GPIO pins can be safely drawn?
    It depends a bit on model but generally try to budget 50mA or less per pin and no more than 200mA total across all pins. For higher needs, an externally powered hub should be used.

  4. What is the maximum speed of the hardware serial port or I2C interfaces?
    The hardware UART port typically runs up to 920Kbps. I2C SCL frequency can be up to around 400KHz in Hi-Speed mode. SPI clocks may reach 30MHz or more.

  5. How many buttons with built-in pull up/down resistors can read at once?
    Raspberry Pi supports up to 64 button inputs total using the internal pull up/down resistors though 8 or less is more common for most projects.

  6. What pins offer analog input capability?
    Pins 35, 36, 37 and 38 on the GPIO support external analog voltage input via the built-in ADC. Sampling rates between 55-200kSPS are typical depending on model.

  7. Can I connect common analog sensors like temperature and humidity directly?
    Generally no, as additional signal conditioning is often still needed to achieve useful precision. Consider modules with integrated electronics that output a digital interface like I2C which are plug and play.

  8. What is the role of pull up/down resistors on GPIO pins?
    Resistors help ensure the input settles at a known 3.3V logic level when an external switch, for example, is open. This avoids erroneous state readings. 1k to 10k values are commonly used.

  9. Is voltage regulation required when supplying power to components?
    It’s always a good practice to regulate supply voltages fed into GPIO pins especially from sources like batteries. Avoid spikes above 3.3V. Basic linear or step-down regulators are inexpensive and add protection.

  10. Can GPIO pins be used to control household 120/220VAC powered devices?
    No, GPIO pins can only directly interface lower voltage DC devices. To control higher voltages, use the GPIO to trigger a mechanical relay or solid state relay module matched to the target device requirements.

  11. Is soldering or breadboard prototype required or can devices plug directly into the GPIO header?
    For most DIY or custom circuits a breakout board, cable or prototype wire harness is required before final soldered assembly. Direct clipping of wires or devices into the GPIO header is risky and should be avoided.

  12. Do newer Raspberry Pi models use the same GPIO layout and numbering schemes?
    Yes, for consistency across models the group developing the Pi’s has retained similarity in the GPIO pinout between generations so that accessories carry over nicely. Always check docs for your specific model though.

  13. Can Pi GPIO pins be damaged from electrostatic discharge when handling?
    Yes! The exposed pins on the SoC can be susceptible to sudden ESD events, especially in cold, dry environments that build up static charge. Use a grounded wrist strap when handling your Pi to avoid risk of damage.

  14. If connecting the Pi to an older RS232 level serial device, what should be used?
    You need a USB to Serial UART TTL converter to safely adapt between the 3.3V UART port voltage and older +/- 12V RS232 serial device pinouts. This avoids any damage while enabling compatibility.

  15. What GPIO interfaces are best to use with common LCD displays?
    Small character or graphical LCDs are often either I2C or SPI interfaced. The SPI is best for faster full screen updates. Some have parallel modes which can also work with many GPIO pins.

  16. What is the difference between the ID_SD and ID_SC pins on the GPIO header?
    ID_SD is connected to an I2C based EEPROM used to identify Pi model information. ID_SC provides a unique chip select number associated with the Broadcom SoC itself.

  17. What are some common uses for the GPIO_GEN0 and GPIO_GEN1 pins?
    Their generic nature makes them flexible for many needs. Often they act as additional interrupt or status signal inputs or custom slave selects for devices using the SPI port.

  18. Can a single Raspberry Pi control multiple SPI devices simultaneously?
    Yes, up to two SPI devices can share the common clock and data lines. The presence of two chip select signals CE0 and CE1 facilitates access to the devices individually via software.

Leave a Comment