Raspberry Pi 2 Pin Assignments

Note that the schematic for the Raspberry Pi 2 Model B has not been released so we are unable to confirm if there are any changes to the specific signals used on the display and camera connectors.

Changes Compared to Raspberry Pi 1

The Raspberry Pi 2 uses a new processor model so some pin additional functions may have changed.

The same GPIO pins are used for the Raspberry Pi 2 (e.g. GPIO2, GPIO3, etc).

The GND, +5V, +3V3, UART, I2C and SPI bus pins are in the same places.

The PWM specific pin is no longer marked as PWM and now 7 pins are marked as 'GPIO GEN0' to 'GPIO GEN6'.

IO Pins

All IO pins are 3.3V, not 1.8V.  Pins are not 5V tolerant.

Full details are available here

Power-up State

Its likely all pins are set as inputs on power up (TBC).

I2C pins (e.g. Pj-3 and P8-5) are therefore high due to the pull up resistors on these pins.

I2C

Pull up resistors are included on the RPi board so are not needed externally (true for RPi1 Model B so presumably true for RPi 2 Model B, but not confirmed as full schematic not yet available).

Interfacing the RPi 3.3V I2C pins to a 5V device like an Arduino – see here.

SPI

The Chip Select signals are for up to two independent slave devices.  It seems that with the SPI port enabled in Raspbian both the CS0 and CS1 pins are assigned to it and therefore can't be used as IO (our assumption – correct?)

3.3V / 5V Interfacing

See our other page here

ID_SD & ID_SC Pins

These are for an auto configuration eeprom which you can include on your RPi add on board and which Raspbian will read to detect the board connected.  For more info see here.

 

 

 

We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.

Raspberry Pi 2 & 3 Pin Mappings

  • 5 minutes to read
  • Contributors

Hardware interfaces for the Raspberry Pi 2 and Raspberry Pi 3 are exposed through the 40-pin header J8 on the board. Functionality includes:

  • 24x - GPIO pins
  • 1x - Serial UARTs (RPi3 only includes mini UART)
  • 2x - SPI bus
  • 1x - I2C bus
  • 2x - 5V power pins
  • 2x - 3.3V power pins
  • 8x - Ground pins

GPIO Pins

Let's look at the GPIO available on this device.

GPIO Pin Overview

The following GPIO pins are accessible through APIs:

GPIO#Power-on PullAlternate FunctionsHeader Pin
2PullUpI2C1 SDA3
3PullUpI2C1 SCL5
4PullUp7
5PullUp29
6PullUp31
7PullUpSPI0 CS126
8PullUpSPI0 CS024
9PullDownSPI0 MISO21
10PullDownSPI0 MOSI19
11PullDownSPI0 SCLK23
12PullDown32
13PullDown33
16PullDownSPI1 CS036
17PullDown11
18PullDown12
19PullDownSPI1 MISO35
20PullDownSPI1 MOSI38
21PullDownSPI1 SCLK40
22PullDown15
23PullDown16
24PullDown18
25PullDown22
26PullDown37
27PullDown13
35*PullUpRed Power LED
47*PullUpGreen Activity LED

* = Raspberry Pi 2 ONLY. GPIO 35 & 47 are not available on Raspberry Pi 3.

GPIO Sample

As an example, the following code opens GPIO 5 as an output and writes a digital '1' out on the pin:

When you open a pin, it will be in its power-on state, which may include a pull resistor. To disconnect the pull resistors and get a high-impedance input, set the drive mode to GpioPinDriveMode.Input:

When a pin is closed, it reverts to its power-on state.

Pin Muxing

Some GPIO pins can perform multiple functions. By default, pins are configured as GPIO inputs. When you open an alternate function by calling or , the pins required by the function are automatically switched ("muxed") to the correct function. When the device is closed by calling or , the pins revert back to their default function. If you try to use a pin for two different functions at once, an exception will be thrown when you try to open the conflicting function. For example,

Serial UART

There is one Serial UART available on the RPi2/3: UART0

  • Pin 8 - UART0 TX
  • Pin 10 - UART0 RX

The example below initializes UART0 and performs a write followed by a read:

Note that you must add the following capability to the Package.appxmanifest file in your UWP project to run Serial UART code:

Visual Studio 2017 has a known bug in the Manifest Designer (the visual editor for appxmanifest files) that affects the serialcommunication capability. If your appxmanifest adds the serialcommunication capability, modifying your appxmanifest with the designer will corrupt your appxmanifest (the Device xml child will be lost). You can workaround this problem by hand editting the appxmanifest by right-clicking your appxmanifest and selecting View Code from the context menu.

I2C Bus

Let's look at the I2C bus available on this device.

I2C Overview

There is one I2C controller I2C1 exposed on the pin header with two lines SDA and SCL. 1.8KΩ internal pull-up resistors are already installed on the board for this bus.

Signal NameHeader Pin NumberGpio Number
SDA32
SCL53

The example below initializes I2C1 and writes data to an I2C device with address 0x40:

SPI Bus

There are two SPI bus controllers available on the RPi2/3.

SPI0

Signal NameHeader Pin NumberGpio Number
MOSI1910
MISO219
SCLK2311
CS0248
CS1267

SPI1

Signal NameHeader Pin NumberGpio Number
MOSI3820
MISO3519
SCLK4021
CS03616

SPI Sample

An example of how to perform a SPI write on bus SPI0 using chip select 0 is shown below:

0 Thoughts to “Raspberry Pi 2 Pin Assignments

Leave a comment

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *