Function: what a Raspberry Pi Zero 2 W does in a circuit
A very small, low-cost Linux computer with Wi-Fi. It runs the same Python programs and has the same 40 header pins as the bigger Raspberry Pi boards.
- Runs your Python program on a very small Linux computer
- Switches and reads 26 GPIO pins at 3.3 V
- Joins a project to Wi-Fi and Bluetooth
- Fits inside small projects such as cameras and robots
Raspberry Pi Zero 2 W key facts
| Processor | Broadcom BCM2710A1, four ARM Cortex-A53 cores at 1 GHz, inside the RP3A0 package |
|---|---|
| Memory | 512 MB RAM (in the same package); programs and files on a microSD card |
| Wireless | 2.4 GHz Wi-Fi (802.11 b/g/n) and Bluetooth 4.2 |
| GPIO voltage | 3.3 V (pins are not 5 V tolerant) |
| GPIO current | about 16 mA from one pin, about 50 mA from all pins together |
| Header | 40-pin layout, the same as the Pi 4; sold without pins (Zero 2 WH has them fitted) |
| Analog inputs | none (add an ADC chip such as the MCP3008) |
| Fixed pull-ups | 1.8 kΩ on GPIO 2 (SDA) and GPIO 3 (SCL) |
| Ports | mini HDMI, one micro USB for devices, one micro USB for power, camera connector |
| Power | 5 V, 2.5 A through micro USB |
| Size | 65 mm × 30 mm |
- What the Raspberry Pi Zero 2 W is
- What the Raspberry Pi Zero 2 W is for
- How the Raspberry Pi Zero 2 W runs your program and its pins
- How to use the Raspberry Pi Zero 2 W in the simulator
- Worked example
- Common mistakes
- Key words
- What to learn first and next
What the Raspberry Pi Zero 2 W is
The Raspberry Pi Zero 2 W is a very small single-board computer: a complete computer on a circuit board only 65 mm long and 30 mm wide, about the size of a stick of chewing gum. It has a processor with four cores that runs at 1 GHz, 512 MB of memory, Wi-Fi and Bluetooth. The processor and the memory are stacked inside one black package called the RP3A0. To keep the board small there is one mini HDMI socket for a screen, one micro USB socket for a device such as a keyboard, a second micro USB socket only for power, and a connector for a camera. The operating system and your files are kept on a microSD card.
What makes it useful for electronics is the row of 40 metal pins along one edge, called the header. A program can switch 26 of these pins on and off, or read them, so the board can light LEDs, read buttons and sensors, and control motors through driver parts. This is different from a microcontroller board such as the Arduino Uno or the Raspberry Pi Pico. A microcontroller runs one program, starts in an instant and has no operating system. A Raspberry Pi computer runs many programs at once under an operating system, usually a version of Linux called Raspberry Pi OS, and is usually programmed in Python.
The Zero 2 W came out in 2021. It runs the same Raspberry Pi OS and the same Python programs as a Raspberry Pi 4, only more slowly and with less memory, and its 40 pins have the same numbers. A real board is sold with empty holes where the header goes, so you solder the pins on yourself or buy the Zero 2 WH, which has them fitted. In the simulator the pins are fitted.
What the Raspberry Pi Zero 2 W is for
- Small projects with a full computer inside. A wildlife camera, a robot, a smart doorbell or a handheld game.
- Projects on a network. Wi-Fi and Bluetooth are built in, so it can send readings or be controlled from a phone.
- Projects left running. It uses little power for a Linux computer, so it can run all day from a USB power bank.
- Learning Python with hardware at low cost: the pins and libraries are the same as on the larger boards.
- Not the best choice for a desktop computer (512 MB is little memory) or for reading analog sensors directly.
How the Raspberry Pi Zero 2 W runs your program and its pins
Starting up. When power is connected, the processor loads the operating system from the microSD card. This takes some seconds. After that you open a terminal, which is a window where you type commands, and start your program with python3 name.py. The program runs until it ends or until you press Ctrl+C. In the simulator, Run starts the program and Stop is Ctrl+C, so the lines after except KeyboardInterrupt: and finally: still run.
The header. The 40 pins are in two rows of 20. Every pin has a physical number from 1 to 40, counted by position: odd numbers are on the inner row and even numbers on the row at the edge. Twelve pins are for power: two give 5 V (pins 2 and 4), two give 3.3 V (pins 1 and 17) and eight are GND. Two pins (27 and 28) are kept for add-on boards. The other 26 are GPIO pins, and each of those also has a GPIO number. Physical pin 11, for example, is GPIO 17, and physical pin 16 is GPIO 23.
What a GPIO pin does. As an output, a pin is either HIGH (3.3 V) or LOW (0 V). As an input, a voltage near 0 V reads LOW and a voltage near 3.3 V reads HIGH. One pin can safely give about 16 mA, and all the pins together about 50 mA. The pins are not 5 V tolerant: 5 V on a GPIO pin damages the board. There is no analog input, so a sensor that gives a changing voltage is read through a converter chip such as the MCP3008.
Two ways to number pins in RPi.GPIO. The RPi.GPIO library makes you choose first. GPIO.setmode(GPIO.BOARD) means the numbers in your program are physical pin numbers. GPIO.setmode(GPIO.BCM) means they are GPIO numbers. Then GPIO.setup(11, GPIO.OUT) makes a pin an output and GPIO.output(11, GPIO.HIGH) switches it on. For an input, GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_UP) switches on a pull-up resistor inside the board, and GPIO.input(15) reads the pin. GPIO.cleanup() at the end gives the pins back.
The gpiozero library. gpiozero is a second library that hides the setup. It always counts by GPIO number. led = LED(17) then led.on() does the same job as the three RPi.GPIO lines above, and Button(22) switches on the pull-up for you. Both libraries work on this board. Only gpiozero works on the newer Raspberry Pi 5.
How to use the Raspberry Pi Zero 2 W in the simulator
- Open the Free build and choose Raspberry Pi Zero 2 W (Python) under Board, or open the Studio and add the board from Components › Boards.
- Read the starter program in the Code panel. It blinks physical pin 11 with
RPi.GPIOin BOARD numbering. - Wire the circuit: physical pin 11 (GPIO 17) to a 330 Ω resistor, the resistor to the long leg of an LED, and the short leg to a GND pin such as pin 6. Point at a header pin to see its physical number and its GPIO number.
- Press Run. The LED blinks and the terminal panel shows what the program prints.
- Press Stop. It acts like Ctrl+C in a real terminal, and
GPIO.cleanup()runs. - Then open a guided project below, such as “Doorbell with a button and a buzzer”, and press Check when your program works.
Worked example
Question. A red LED with a forward voltage of about 2.0 V is wired to physical pin 11 of a Raspberry Pi Zero 2 W through a 330 Ω resistor. How much current does the pin give, and is that safe? What is the line of code that sets up the pin?
- A pin that is HIGH gives 3.3 V.
- The LED takes about 2.0 V, so the resistor gets 3.3 V − 2.0 V = 1.3 V.
- Current = voltage ÷ resistance = 1.3 V ÷ 330 Ω = 0.0039 A, which is 3.9 mA.
- Physical pin 11 is GPIO 17. With GPIO.setmode(GPIO.BOARD) the program uses the number 11.
- The line is
GPIO.setup(11, GPIO.OUT).
Answer. The pin gives about 3.9 mA, which is safe. The pin is set up with GPIO.setup(11, GPIO.OUT).
Common mistakes
- Leaving out GPIO.setmode().RPi.GPIO stops with “Please set pin numbering mode”. Write GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM) before the first GPIO.setup().
- Mixing up physical pin numbers and GPIO numbers.Physical pin 11 is GPIO 17. In BOARD mode write 11; in BCM mode and in gpiozero write 17.
- Connecting a 5 V signal to a GPIO pin.The pins are 3.3 V only. A 5 V output, such as the Echo pin of an HC-SR04, needs a voltage divider: 1 kΩ and 2 kΩ turn 5 V into about 3.3 V.
- Wiring an LED with no resistor.The pin would try to give far more than 16 mA. Always put a resistor of about 330 Ω in series.
- Reading a button with no pull-up.The pin floats and reads random values. Add pull_up_down=GPIO.PUD_UP and wire the button to GND, or use a gpiozero Button.
- Writing time.sleep(500) for half a second.Python counts in seconds, not milliseconds. Half a second is time.sleep(0.5).
- Plugging the power supply into the USB data socket.The two micro USB sockets look the same. Power goes into the one marked PWR IN, at the end of the board.
- Expecting the pins to be there on a new board.A Zero 2 W has an empty header footprint. Buy the Zero 2 WH or solder a 40-pin header on.
Key words
- Single-board computer
- A complete computer, with processor, memory and sockets, built on one circuit board.
- Operating system
- The main program of a computer, which starts other programs and shares the processor, memory and devices between them. Linux and Windows are examples.
- GPIO
- General-purpose input and output: a pin that a program can set HIGH or LOW, or read.
- Header (on a circuit board)
- A row of metal pins on a board for connecting wires or add-on boards.
- Physical pin number
- The position of a pin on the 40-pin header of a Raspberry Pi, counted from 1 to 40.
- GPIO number
- The number the Raspberry Pi gives to a GPIO pin, also called its BCM number. It is not the same as the position of the pin.
- Library (in programming)
- Code written by someone else that a program can import and use, such as gpiozero.
- gpiozero
- A Python library for the pins of a Raspberry Pi, with ready-made objects such as LED and Button.
- Pull-up resistor
- A resistor that joins an input pin to the supply voltage, so the pin reads HIGH when nothing else drives it.
- System-in-package
- Several chips, such as a processor and its memory, sealed together inside one package.
- LED
- A light-emitting diode: a component that gives out light when current flows through it in one direction.
- Resistor
- A component made to have a fixed resistance.
- Forward voltage
- The voltage across an LED or diode when it is conducting.
- Voltage divider
- Two resistors in series that share a voltage, with the output taken from where they join. Also called a potential divider.
- Ground
- The point in a circuit taken as zero volts, from which other voltages are measured.
See every key word in the glossary
What to learn first and next
- Ohm’s law calculator: Voltage, current and resistance, which the worked example uses.
- LED resistor calculator: Work out the resistor that an LED needs on a 3.3 V pin.
- LED: The first part to connect to a pin.
- Doorbell with a button and a buzzer: The guided project for this board.
- Raspberry Pi 4 Model B: The larger board with the same header.
- MCP3008 analog-to-digital converter: Read a knob or an analog sensor.
- Raspberry Pi Pico 2: A microcontroller board of about the same size.
- Raspberry Pi course: Every Raspberry Pi lesson in teaching order.
How it works
At its centre is one black package called the RP3A0. Inside that package are a four-core 1 GHz ARM processor (the BCM2710A1) and 512 MB of memory, stacked together to save space. This is called a system-in-package. The board runs the Linux operating system from a microSD card, so a program starts from a terminal with python3 name.py, exactly as on a Raspberry Pi 4. The 40-pin header has the same layout: 26 GPIO pins at 3.3 V, two 5 V pins, two 3.3 V pins and eight GND pins, and both the RPi.GPIO and gpiozero libraries work. The board is only 65 mm × 30 mm, so there is one small USB socket for devices, a mini HDMI socket for a screen, and a second USB socket that is only for power. Wi-Fi and Bluetooth are built in. There is no analog input. A real Zero 2 W is sold with empty holes where the header goes; the version with the pins already soldered on is called the Zero 2 WH. In this simulator the header is fitted.
What it is made of
- RP3A0 package: A silicon processor chip and a silicon memory chip stacked inside one package SiCuAl
- Wireless module: A radio chip and antenna circuit under a metal shield SiCuFe
- Circuit board: Layers of glass-fibre and epoxy with copper tracks CuSiO
- Header and ports: Gold-plated brass pins, steel port shells CuZnAuFe
- Solder: Lead-free tin alloy SnAgCu
Where the materials come from: Silicon purified from quartz sand; copper from ores in Chile and Peru; tin from Indonesia and China; gold for the pin plating from many mining countries. The boards are assembled in Wales.
The chemistry
Stacking the memory chip on top of the processor keeps the gold or copper connections between them only a few millimetres long. Short connections carry fast signals with less loss, and the whole computer fits under one square of black epoxy resin.
Biology connection
Packing a processor and memory into one small package is like the way a cell packs different jobs into separate organelles inside one membrane: everything a task needs is close together. Cell organelles →
Safety and the environment
Never connect 5 V to a GPIO pin: the pins are 3.3 V only. A 5 V sensor output such as the HC-SR04 Echo pin needs a voltage divider. Plug the power supply into the socket marked PWR IN, not the USB data socket. Shut the Pi down before unplugging it so the microSD card is not corrupted. Recycle as e-waste.
Did you know? The Raspberry Pi Zero 2 W went on sale in 2021. Its designer hid a tiny Raspberry Pi logo in the pattern of solder balls under the RP3A0 package, where only an X-ray can see it.
Raspberry Pi 4 Model BRaspberry Pi 5Raspberry Pi Pico 2MCP3008 analog-to-digital converterPiezo buzzerMicrocontroller simulatorOhm’s law calculator Elements inside: SiCuAlFeOZnAuSnAg
Try it in the simulator
Build and code a circuit with a Raspberry Pi Zero 2 W in these practice projects:
Questions students ask
What does a Raspberry Pi Zero 2 W do?
A very small, low-cost Linux computer with Wi-Fi. It runs the same Python programs and has the same 40 header pins as the bigger Raspberry Pi boards. Main functions: runs your Python program on a very small Linux computer; switches and reads 26 GPIO pins at 3.3 V; joins a project to Wi-Fi and Bluetooth; fits inside small projects such as cameras and robots.
Is a Raspberry Pi Zero 2 W programmed the same way as a Raspberry Pi 4?
Yes. A Raspberry Pi Zero 2 W runs the same Raspberry Pi OS and the same Python programs as a Raspberry Pi 4, and its 40 header pins have the same numbers, so RPi.GPIO and gpiozero code works without changes. The Zero 2 W is smaller, slower and has 512 MB of memory, one USB socket for devices and no Ethernet socket.
How does a Raspberry Pi Zero 2 W work?
At its centre is one black package called the RP3A0. Inside that package are a four-core 1 GHz ARM processor (the BCM2710A1) and 512 MB of memory, stacked together to save space. This is called a system-in-package. The board runs the Linux operating system from a microSD card, so a program starts from a terminal with python3 name.py, exactly as on a Raspberry Pi 4. The 40-pin header has the same layout: 26 GPIO pins at 3.3 V, two 5 V pins, two 3.3 V pins and eight GND pins, and both the RPi.GPIO and gpiozero libraries work. The board is only 65 mm × 30 mm, so there is one small USB socket for devices, a mini HDMI socket for a screen, and a second USB socket that is only for power. Wi-Fi and Bluetooth are built in. There is no analog input. A real Zero 2 W is sold with empty holes where the header goes; the version with the pins already soldered on is called the Zero 2 WH. In this simulator the header is fitted.
What is a Raspberry Pi Zero 2 W made of?
RP3A0 package: A silicon processor chip and a silicon memory chip stacked inside one package. Wireless module: A radio chip and antenna circuit under a metal shield. Circuit board: Layers of glass-fibre and epoxy with copper tracks. Header and ports: Gold-plated brass pins, steel port shells. Solder: Lead-free tin alloy.
Is a Raspberry Pi Zero 2 W safe? How should it be recycled?
Never connect 5 V to a GPIO pin: the pins are 3.3 V only. A 5 V sensor output such as the HC-SR04 Echo pin needs a voltage divider. Plug the power supply into the socket marked PWR IN, not the USB data socket. Shut the Pi down before unplugging it so the microSD card is not corrupted. Recycle as e-waste.
More boards and wiring
Connected tools
The same idea from another angle, across the site.