Loading the figure…
A quad-core Linux computer on an 85 x 56 mm board: Python with gpiozero on 40 GPIO pins, and ROS 2 for robots
Each lesson runs your own code on the board. Finish its checks to tick it off.
Build the board in the right order, then power it up and check it, as on the bench.
0 of 11 stepsStrip the Pi to its bare PCB: an 85 x 56 mm board with four 2.7 mm mounting holes on a 58 x 49 mm grid and the 40-pin header's footprint along the top edge. Both sides carry parts.
Each fault really happens in the simulation. Trigger one, watch the figure, then read why.
Raspberry Pi's single-board computers. The Raspberry Pi 5 carries a Broadcom BCM2712 (four Arm Cortex-A76 cores at 2.4 GHz and a VideoCore VII GPU) with 1 to 16 GB of LPDDR4X, and hands every port to RP1, Raspberry Pi's own I/O chip, over a PCIe link: USB, Ethernet, the camera and display lanes and the header's GPIO pins all live in RP1. A DA9091 PMIC with eight switching regulators makes every rail from 5 V on USB-C and keeps a real-time clock with a battery connector. The Raspberry Pi 4 Model B has the same outline and the same 40-pin header but an older layout: a BCM2711 (four Cortex-A72 cores at 1.8 GHz), LPDDR4, a VL805 USB 3 controller, a 3.5 mm A/V jack and no power button. Neither board has flash to upload to: a program is a file on the microSD card, and you run it on Linux, usually over SSH. Every GPIO runs at 3.3 V, takes no more than 16 mA, and is not 5 V tolerant. The 5 V header pins sit right on the input rail with nothing in between, so a supply there must be clean and the right way round.
| Header | Pin | Name | Functions | Level | Max current | Notes |
|---|---|---|---|---|---|---|
| J8 | 1 | 3V3 | 3.3 V power | 3.3 V | – | The PMIC's 3.3 V rail, shared with the GPIO bank. Good for sensors and small HATs, not for motors. |
| J8 | 2 | 5V | 5 V power (the input rail itself) | 5 V | – | Straight on the 5 V input rail, with no protection. As an output it gives whatever the USB-C supply gives; as an input it powers the whole Pi, so it must be a clean 5 V, the right way round. |
| J8 | 3 | GPIO2 | I2C1 SDA | 3.3 V | 16 mA | I2C1 SDA, with a fixed 1.8 kΩ pull-up to 3.3 V on the board, so it reads high when nothing drives it. |
| J8 | 4 | 5V | 5 V power (the input rail itself) | 5 V | – | Straight on the 5 V input rail, with no protection. As an output it gives whatever the USB-C supply gives; as an input it powers the whole Pi, so it must be a clean 5 V, the right way round. |
| J8 | 5 | GPIO3 | I2C1 SCL | 3.3 V | 16 mA | I2C1 SCL, with a fixed 1.8 kΩ pull-up. Pulling it low wakes a halted Pi 4; a Pi 5 has its power button for that. |
| J8 | 6 | GND | – | – | – | |
| J8 | 7 | GPIO4 | GPCLK0, 1-Wire (w1-gpio) | 3.3 V | 16 mA | |
| J8 | 8 | GPIO14 | UART0 TXD | 3.3 V | 16 mA | UART0 TXD (/dev/ttyAMA0 on a Pi 5). On a Pi 4 it carries the serial console when enable_uart=1 is set; a Pi 5 has a separate UART connector for that. |
| J8 | 9 | GND | – | – | – | |
| J8 | 10 | GPIO15 | UART0 RXD | 3.3 V | 16 mA | UART0 RXD. Its partner is GPIO14 on pin 8. |
| J8 | 11 | GPIO17 | SPI1 CE1 | 3.3 V | 16 mA | |
| J8 | 12 | GPIO18 | PCM CLK, PWM0 | 3.3 V | 16 mA | One of the four hardware PWM pins (12, 13, 18, 19). gpiozero's PWMLED still uses software PWM through lgpio, on any pin. |
| J8 | 13 | GPIO27 | – | 3.3 V | 16 mA | |
| J8 | 14 | GND | – | – | – | |
| J8 | 15 | GPIO22 | – | 3.3 V | 16 mA | |
| J8 | 16 | GPIO23 | – | 3.3 V | 16 mA | |
| J8 | 17 | 3V3 | 3.3 V power | 3.3 V | – | The PMIC's 3.3 V rail, shared with the GPIO bank. Good for sensors and small HATs, not for motors. |
| J8 | 18 | GPIO24 | – | 3.3 V | 16 mA | |
| J8 | 19 | GPIO10 | SPI0 MOSI | 3.3 V | 16 mA | |
| J8 | 20 | GND | – | – | – | |
| J8 | 21 | GPIO9 | SPI0 MISO | 3.3 V | 16 mA | |
| J8 | 22 | GPIO25 | – | 3.3 V | 16 mA | |
| J8 | 23 | GPIO11 | SPI0 SCLK | 3.3 V | 16 mA | |
| J8 | 24 | GPIO8 | SPI0 CE0 | 3.3 V | 16 mA | |
| J8 | 25 | GND | – | – | – | |
| J8 | 26 | GPIO7 | SPI0 CE1 | 3.3 V | 16 mA | |
| J8 | 27 | GPIO0 | ID_SD (HAT EEPROM, reserved) | 3.3 V | 16 mA | Reserved for the HAT ID EEPROM (I2C0 SDA). Leave it free unless you know you don't need it. |
| J8 | 28 | GPIO1 | ID_SC (HAT EEPROM, reserved) | 3.3 V | 16 mA | Reserved for the HAT ID EEPROM (I2C0 SCL). |
| J8 | 29 | GPIO5 | – | 3.3 V | 16 mA | |
| J8 | 30 | GND | – | – | – | |
| J8 | 31 | GPIO6 | – | 3.3 V | 16 mA | |
| J8 | 32 | GPIO12 | PWM0 | 3.3 V | 16 mA | |
| J8 | 33 | GPIO13 | PWM1 | 3.3 V | 16 mA | |
| J8 | 34 | GND | – | – | – | |
| J8 | 35 | GPIO19 | PCM FS, PWM1, SPI1 MISO | 3.3 V | 16 mA | |
| J8 | 36 | GPIO16 | SPI1 CE2 | 3.3 V | 16 mA | |
| J8 | 37 | GPIO26 | – | 3.3 V | 16 mA | |
| J8 | 38 | GPIO20 | PCM DIN, SPI1 MOSI | 3.3 V | 16 mA | |
| J8 | 39 | GND | – | – | – | |
| J8 | 40 | GPIO21 | PCM DOUT, SPI1 SCLK | 3.3 V | 16 mA |
Sensors and actuators this board drives, with the real connections.
Anode (long leg) to GPIO17 on pin 11 through a 330 Ω resistor, cathode to GND on pin 9: about 4 mA from 3.3 V. gpiozero calls it LED(17).
| Part pin | Board pin |
|---|---|
| A | GPIO17Wire colour orange |
| K | GNDWire colour black |
Never connect an LED without its resistor: the pin would try to source far more than 16 mA.
One leg to GPIO27 on pin 13, the other to GND on pin 14. gpiozero's Button turns on the internal pull-up, so no resistor is needed: the pin reads high until you press.
| Part pin | Board pin |
|---|---|
| 1 | GPIO27Wire colour yellow |
| 3 | GNDWire colour black |
VCC to 5V on pin 2, GND to pin 6, TRIG to GPIO23 on pin 16 (3.3 V is enough to trigger it), ECHO to GPIO24 on pin 18 through a divider: 1 kΩ in series, 2 kΩ to GND.
| Part pin | Board pin |
|---|---|
| VCC | 5VWire colour red |
| TRIG | GPIO23Wire colour yellow |
| ECHO | GPIO24Wire colour green |
| GND | GNDWire colour black |
ECHO is a 5 V output. Straight into a GPIO pin it pushes current through the pad's protection diode into the 3.3 V rail and can kill the pin or the whole I/O chip.
Signal to GPIO18 on pin 12, red to 5V, brown to GND. gpiozero's Servo and AngularServo make the 50 Hz pulses in software, so expect a little jitter; a PCA9685 board gives steady pulses.
| Part pin | Board pin |
|---|---|
| signal | GPIO18Wire colour orange |
| V+ | 5VWire colour red |
| GND | GNDWire colour brown |
A servo's stall current comes out of the Pi's 5 V rail. One SG90 is fine; for more, give them their own 5 V supply with a common ground.
VCC to 3V3, GND to GND, SDA to GPIO2 (pin 3), SCL to GPIO3 (pin 5). The board's 1.8 kΩ pull-ups are already on those pins. Enable I2C with raspi-config and check with i2cdetect -y 1: it answers at 0x68.
| Part pin | Board pin |
|---|---|
| VCC | 3V3Wire colour red |
| GND | GNDWire colour black |
| SCL | GPIO3Wire colour yellow |
| SDA | GPIO2Wire colour blue |
GND, VCC to 3V3, SCL to GPIO3, SDA to GPIO2: the same I2C bus as other sensors, usually at address 0x3C.
| Part pin | Board pin |
|---|---|
| GND | GNDWire colour black |
| VCC | 3V3Wire colour red |
| SCL | GPIO3Wire colour yellow |
| SDA | GPIO2Wire colour blue |
Plus to GPIO22 on pin 15, minus to GND. An active buzzer just needs gpiozero's Buzzer(22); a passive one needs a tone, from TonalBuzzer.
| Part pin | Board pin |
|---|---|
| + | GPIO22Wire colour orange |
| - | GNDWire colour black |