Los pines GPIO (General Purpose Input/Output) de la Raspberry Pi son conexiones físicas que permiten a la placa interactuar con el mundo exterior. Funcionan como interruptores programables para leer entradas (como pulsar un botón o los datos de un sensor) y controlar salidas (encender un LED o un motor) enviando o recibiendo señales de 3.3 V.
GPIO de Raspberry Pi 4 y Raspberry Pi 5
La Raspberry Pi 4 Model B y la Raspberry Pi 5 utilizan el mismo conector GPIO de 40 pines (J8), por lo que son completamente compatibles con la mayoría de HATs y accesorios diseñados para Raspberry Pi. Todos los GPIO funcionan con lógica de 3.3 V (no son tolerantes a 5 V). La Raspberry Pi 5 incorpora un nuevo controlador GPIO (RP1), pero mantiene el mismo pinout físico que la Raspberry Pi 4.
| 3v3 | 1 | 2 | 5v | ||
| SDA I2C1 | GPIO 2 | 3 | 4 | 5v | |
| SCL I2C1 | GPIO 3 | 5 | 6 | GND | |
| GPCLK0 | GPIO 4 | 7 | 8 | GPIO 14 | TX UART0 |
| GND | 9 | 10 | GPIO 15 | RX UART0 | |
| GPIO 17 | 11 | 12 | GPIO 18 | PCM CLK | |
| GPIO 27 | 13 | 14 | GND | ||
| GPIO 22 | 15 | 16 | GPIO 23 | ||
| 3v3 | 17 | 18 | GPIO 24 | ||
| MOSI SPI0 | GPIO 10 | 19 | 20 | GND | |
| MISO SPI0 | GPIO 9 | 21 | 22 | GPIO 25 | |
| SCLK SPI0 | GPIO 11 | 23 | 24 | GPIO 8 | CE0 SPI0 |
| GND | 25 | 26 | GPIO 7 | CD1SPI0 | |
| SDA EEPROM | GPIO 0 | 27 | 28 | GPIO 1 | SCL EEPROM |
| GPIO 5 | 29 | 30 | GND | ||
| GPIO 6 | 31 | 32 | GPIO 12 | PWM0 | |
| PWM1 | GPIO 13 | 33 | 34 | GND | |
| PCM FS | GPIO 19 | 35 | 36 | GPIO 16 | |
| GPIO 26 | 37 | 38 | GPIO 20 | PCM DIN | |
| GND | 39 | 40 | GPIO 21 | PCM DOUT |
| Pin Físico | GPIO (BCM) | Función Principal |
|---|---|---|
| 1 | - | 3.3V |
| 2 | - | 5V |
| 3 | GPIO2 | I2C SDA1 |
| 4 | - | 5V |
| 5 | GPIO3 | I2C SCL1 |
| 6 | - | GND |
| 7 | GPIO4 | GPCLK0 |
| 8 | GPIO14 | UART TXD |
| 9 | - | GND |
| 10 | GPIO15 | UART RXD |
| 11 | GPIO17 | GPIO |
| 12 | GPIO18 | PWM / PCM CLK |
| 13 | GPIO27 | GPIO |
| 14 | - | GND |
| 15 | GPIO22 | GPIO |
| 16 | GPIO23 | GPIO |
| 17 | - | 3.3V |
| 18 | GPIO24 | GPIO |
| 19 | GPIO10 | SPI MOSI |
| 20 | - | GND |
| 21 | GPIO9 | SPI MISO |
| 22 | GPIO25 | GPIO |
| 23 | GPIO11 | SPI SCLK |
| 24 | GPIO8 | SPI CE0 |
| 25 | - | GND |
| 26 | GPIO7 | SPI CE1 |
| 27 | GPIO0 | ID_SD (EEPROM) |
| 28 | GPIO1 | ID_SC (EEPROM) |
| 29 | GPIO5 | GPIO |
| 30 | - | GND |
| 31 | GPIO6 | GPIO |
| 32 | GPIO12 | PWM |
| 33 | GPIO13 | PWM |
| 34 | - | GND |
| 35 | GPIO19 | PCM FS / SPI |
| 36 | GPIO16 | GPIO |
| 37 | GPIO26 | GPIO |
| 38 | GPIO20 | PCM DIN / SPI |
| 39 | - | GND |
| 40 | GPIO21 | PCM DOUT / SPI |
Interfaces disponibles
| Interfaz | GPIO utilizados |
|---|---|
| I²C | GPIO2 (SDA), GPIO3 (SCL) |
| UART | GPIO14 (TX), GPIO15 (RX) |
| SPI0 | GPIO7, GPIO8, GPIO9, GPIO10, GPIO11 |
| PWM | GPIO12, GPIO13, GPIO18, GPIO19 |
| PCM / I2S | GPIO18, GPIO19, GPIO20, GPIO21 |
¿Hay diferencias entre Raspberry Pi 4 y Raspberry Pi 5?
En cuanto al conector GPIO, no existen diferencias físicas. El encabezado de 40 pines es exactamente el mismo, por lo que el cableado y los proyectos electrónicos son compatibles entre ambos modelos.
La principal diferencia es interna:
- Raspberry Pi 4 utiliza el controlador GPIO integrado en el SoC BCM2711.
- Raspberry Pi 5 utiliza el chip RP1, que gestiona los GPIO y las interfaces de entrada/salida, ofreciendo mejor rendimiento y menor latencia.
- Los niveles eléctricos siguen siendo de 3.3 V.
- Los HAT y accesorios compatibles con Raspberry Pi 4 funcionan, en la gran mayoría de los casos, también en Raspberry Pi 5.
GPIO de Raspberry Pi 3 Model B y Raspberry Pi 3 Model B+
La Raspberry Pi 3 Model B y la Raspberry Pi 3 Model B+ incorporan un conector GPIO (J8) de 40 pines. Este conector es compatible con las Raspberry Pi 2, Raspberry Pi 4 y Raspberry Pi 5, por lo que la mayoría de los módulos HAT y accesorios pueden utilizarse sin modificaciones.
Todos los GPIO trabajan con un nivel lógico de 3.3 V. Ningún pin GPIO admite señales de 5 V, ya que esto podría dañar permanentemente el procesador Broadcom BCM2837.
Tabla de pines GPIO
| Pin Físico | GPIO (BCM) | Nombre | Tipo | Descripción |
|---|---|---|---|---|
| 1 | - | 3V3 | Alimentación | Salida de 3.3 V. |
| 2 | - | 5V | Alimentación | Entrada/salida de 5 V. |
| 3 | GPIO2 | SDA1 | I²C | Línea de datos del bus I²C. |
| 4 | - | 5V | Alimentación | Entrada/salida de 5 V. |
| 5 | GPIO3 | SCL1 | I²C | Reloj del bus I²C. |
| 6 | - | GND | Tierra | Masa del sistema. |
| 7 | GPIO4 | GPCLK0 | GPIO | Entrada/Salida digital o reloj. |
| 8 | GPIO14 | TXD0 | UART | Transmisión serie. |
| 9 | - | GND | Tierra | Masa del sistema. |
| 10 | GPIO15 | RXD0 | UART | Recepción serie. |
| 11 | GPIO17 | GPIO17 | GPIO | Entrada/Salida digital. |
| 12 | GPIO18 | PWM0 | PWM | PWM o PCM_CLK. |
| 13 | GPIO27 | GPIO27 | GPIO | Entrada/Salida digital. |
| 14 | - | GND | Tierra | Masa del sistema. |
| 15 | GPIO22 | GPIO22 | GPIO | Entrada/Salida digital. |
| 16 | GPIO23 | GPIO23 | GPIO | Entrada/Salida digital. |
| 17 | - | 3V3 | Alimentación | Salida de 3.3 V. |
| 18 | GPIO24 | GPIO24 | GPIO | Entrada/Salida digital. |
| 19 | GPIO10 | MOSI | SPI | Datos maestro hacia esclavo. |
| 20 | - | GND | Tierra | Masa del sistema. |
| 21 | GPIO9 | MISO | SPI | Datos esclavo hacia maestro. |
| 22 | GPIO25 | GPIO25 | GPIO | Entrada/Salida digital. |
| 23 | GPIO11 | SCLK | SPI | Reloj SPI. |
| 24 | GPIO8 | CE0 | SPI | Chip Select 0. |
| 25 | - | GND | Tierra | Masa del sistema. |
| 26 | GPIO7 | CE1 | SPI | Chip Select 1. |
| 27 | GPIO0 | ID_SD | I²C | EEPROM de identificación del HAT. |
| 28 | GPIO1 | ID_SC | I²C | EEPROM de identificación del HAT. |
| 29 | GPIO5 | GPIO5 | GPIO | Entrada/Salida digital. |
| 30 | - | GND | Tierra | Masa del sistema. |
| 31 | GPIO6 | GPIO6 | GPIO | Entrada/Salida digital. |
| 32 | GPIO12 | PWM0 | PWM | Salida PWM. |
| 33 | GPIO13 | PWM1 | PWM | Salida PWM. |
| 34 | - | GND | Tierra | Masa del sistema. |
| 35 | GPIO19 | PCM_FS | PCM/I²S | Frame Sync. |
| 36 | GPIO16 | GPIO16 | GPIO | Entrada/Salida digital. |
| 37 | GPIO26 | GPIO26 | GPIO | Entrada/Salida digital. |
| 38 | GPIO20 | PCM_DIN | PCM/I²S | Entrada de datos PCM. |
| 39 | - | GND | Tierra | Masa del sistema. |
| 40 | GPIO21 | PCM_DOUT | PCM/I²S | Salida de datos PCM. |
Interfaces de comunicación disponibles
| Interfaz | GPIO | Pines físicos |
|---|---|---|
| I²C | GPIO2 (SDA), GPIO3 (SCL) | 3 y 5 |
| UART | GPIO14 (TX), GPIO15 (RX) | 8 y 10 |
| SPI0 | GPIO7, GPIO8, GPIO9, GPIO10 y GPIO11 | 19, 21, 23, 24 y 26 |
| PWM | GPIO12, GPIO13, GPIO18 y GPIO19 | 12, 32, 33 y 35 |
| PCM / I²S | GPIO18, GPIO19, GPIO20 y GPIO21 | 12, 35, 38 y 40 |
Compatibilidad con otras Raspberry Pi
La Raspberry Pi 3 Model B y Raspberry Pi 3 Model B+ utilizan exactamente el mismo pinout GPIO que la Raspberry Pi 2, Raspberry Pi 4 y Raspberry Pi 5. Esto significa que los programas desarrollados utilizando la numeración BCM y los accesorios HAT compatibles con el conector de 40 pines pueden utilizarse indistintamente en estos modelos.
La diferencia principal entre estos modelos no está en el conector GPIO, sino en el procesador, la memoria, el rendimiento y el controlador interno encargado de gestionar los GPIO. Mientras la Raspberry Pi 3 utiliza el SoC Broadcom BCM2837 para controlar directamente los GPIO, la Raspberry Pi 5 emplea el chip RP1 como controlador de entrada/salida, aunque mantiene la misma distribución física de los pines.