Does GPIO 2 on Raspberry Pi 5 work like GPIO 4
Short answer: electrically they’re mostly the same as GPIOs, but they are not identical in function or “gotchas”.
Also, be careful: “GPIO 2” ≠ “pin 2” on the header.
1. If you meant physical pin 2 vs pin 4
On Raspberry Pi 5:
-
Pin 2 = 5 V power
-
Pin 4 = 5 V power
Both are fixed 5 V supply pins, not GPIO at all. You cannot use them like GPIO4.
So:
❌ Pin 2 does not work like GPIO 4 (BCM 4).
It’s just a 5 V output from the power supply.
2. If you meant BCM GPIO2 vs BCM GPIO4
On the Raspberry Pi 5 header:
-
GPIO2 = BCM2, physical pin 3 → default I²C1 SDA
-
GPIO4 = BCM4, physical pin 7 → a “normal” GPIO with extras like GPCLK0, and often used as the default 1-Wire pin.
They are similar in that:
-
Both are 3.3 V GPIOs in the same IO bank on Pi 5. You can configure each as input or output in your code.
But they differ in details:
-
Fixed pull-up on GPIO2
-
GPIO2 (and GPIO3) have a permanent pull-up to 3.3 V because they are the main I²C bus (SDA/SCL).
-
That means they never fully float and aren’t ideal if you need a truly “no pull-up” input.
-
-
Different alternate functions
-
On Pi 5, GPIO2 can be things like
I2C1_SDA,UART1_CTS,SPI0_CSn[3], etc. -
GPIO4 can be
GPCLK0,I2C2_SDA,UART2_TX, etc. -
So if you specifically need GPCLK0 or the “classic” 1-Wire pin, use GPIO4, not GPIO2.
-
-
I²C vs “free” GPIO
-
If you use I²C1, GPIO2 is almost always reserved as SDA, while GPIO4 is usually free unless you assign it a special function.
-
TL;DR
-
Physical pin 2: 5 V power → not a GPIO, does not behave like GPIO4.
-
BCM GPIO2: Normal 3.3 V GPIO but with a fixed pull-up and I²C role, not identical to GPIO4.
-
BCM GPIO4: More “generic” GPIO with common extras (GPCLK, default 1-Wire), usually the better pick if you just need a flexible digital pin.

评论
发表评论