ラズパイのGPIOを調べる

ラズパイのGPIOを調べてみる。

GPIOとは

GPIOとはGeneral-Purpose input/outputの略であり、ラズパイの基盤の端の40本のピンのことである。input用のピンとoutput用のピンを適切に使用することで幅広い用途に使用することができる。

↓この左端のピン

20200725-1.jpg

GPIO pinsの役割

ピンは全て同じ役割ではない。各ピンの役割を確認してみよう。ラズパイで「pinout」というコマンドを入力する。

pi@raspberrypi:~ $ pinout
,--------------------------------.
| oooooooooooooooooooo J8   +======
| 1ooooooooooooooooooo  PoE |   Net
|  Wi                    oo +======
|  Fi  Pi Model 4B  V1.2 oo      |
|        ,----.               +====
| |D|    |SoC |               |USB3
| |S|    |    |               +====
| |I|    `----'                  |
|                   |C|       +====
|                   |S|       |USB2
| pwr   |HD|   |HD| |I||A|    +====
`-| |---|MI|---|MI|----|V|-------'

Revision           : c03112
SoC                : BCM2711
RAM                : 4096Mb
Storage            : MicroSD
USB ports          : 4 (excluding power)
Ethernet ports     : 1
Wi-fi              : True
Bluetooth          : True
Camera ports (CSI) : 1
Display ports (DSI): 1

J8:
   3V3  (1) (2)  5V    
 GPIO2  (3) (4)  5V    
 GPIO3  (5) (6)  GND   
 GPIO4  (7) (8)  GPIO14
   GND  (9) (10) GPIO15
GPIO17 (11) (12) GPIO18
GPIO27 (13) (14) GND   
GPIO22 (15) (16) GPIO23
   3V3 (17) (18) GPIO24
GPIO10 (19) (20) GND   
 GPIO9 (21) (22) GPIO25
GPIO11 (23) (24) GPIO8 
   GND (25) (26) GPIO7 
 GPIO0 (27) (28) GPIO1 
 GPIO5 (29) (30) GND   
 GPIO6 (31) (32) GPIO12
GPIO13 (33) (34) GND   
GPIO19 (35) (36) GPIO16
GPIO26 (37) (38) GPIO20
   GND (39) (40) GPIO21

For further information, please refer to https://pinout.xyz/

これでラズパイのどのピンがどのような役割かわかる。だが、further informationを求めてhttps://pinout.xyz/にアクセスしてみる。

かなりわかりやすい上に各pinの詳細の説明を確認することができる。

20200725-2.png

冷却ファンのために3V3(1)とGND(6)を使っているので、まずはそれをみてみる。

3v3 Power

Physical pin 1

The 3v3 supply pin on the early Raspberry Pi had a maximum available current of about 50 mA. Enough to power a couple of LEDs or a microprocessor, but not much more.

All Raspberry Pi since the Model B+ can provide quite a bit more, up to 500mA to remain on the safe side, thanks to a switching regulator.

Still, you should generally use the 5v supply, coupled with a 3v3 regulator for 3.3v projects.

https://pinout.xyz/pinout/pin1_3v3_power

これまでは50mAだったが、現在は最大500mAの電流が流せる、といった内容が書かれている。

次にGND(6)も調べる。

Ground

The Ground pins on the Raspberry Pi are all electrically connected, so it doesn't matter which one you use if you're wiring up a voltage supply.

Generally the one that's most convenient or closest to the rest of your connections is tidier and easier, or alternatively the one closest to the supply pin that you use.

For example, it's a good idea to use Physical Pin 17 for 3v3 and Physical Pin 25 for ground when using the SPI connections, as these are right next to the important pins for SPI0.

Details

1 pin header

Uses 8 GPIO pins

https://pinout.xyz/pinout/ground

Groundのピンは全て電気的に繋がっているため、どれを使用しても問題ない。だが供給側のピンと近い方がオシャレ。みたいなことが書かれている。なおgroundのピンは6,9,14,20,25,30,34,39と8ピンある。

他のピンは割愛するが、使用したい目的に合わせて都度調べてみよう。