libgpiod

libgpiod インストール

$ sudo apt install libgpiod2 libgpiod-dev libgpiod-doc

ドキュメント
ブラウザで開く
/usr/share/doc/libgpiod-dev/html/index.html

gpiod インストール

$ sudo apt install gpiod

GPIO検出チェック

$ gpiodetect
gpiochip0 [pinctrl-bcm2835] (54 lines)

GPIOピンアサイン

$ gpioinfo gpiochip0
gpiochip0 - 54 lines:
        line   0:     "ID_SDA"       unused   input  active-high 
        line   1:     "ID_SCL"       unused   input  active-high 
        line   2:       "SDA1"       unused   input  active-high 
        line   3:       "SCL1"       unused   input  active-high 
        line   4:  "GPIO_GCLK"  "onewire@0"  output  active-high [used open-drain]
        line   5:      "GPIO5"       unused   input  active-high 
        line   6:      "GPIO6"       unused   input  active-high 
        line   7:  "SPI_CE1_N"   "spi0 CS1"  output   active-low [used]
        line   8:  "SPI_CE0_N"   "spi0 CS0"  output   active-low [used]
        line   9:   "SPI_MISO"       unused   input  active-high 
        line  10:   "SPI_MOSI"       unused   input  active-high 
        line  11:   "SPI_SCLK"       unused   input  active-high 
        line  12:     "GPIO12"       unused   input  active-high 
        line  13:     "GPIO13"       unused   input  active-high 
        line  14:       "TXD0"       unused   input  active-high 
        line  15:       "RXD0"       unused   input  active-high 
        line  16:     "GPIO16"       unused   input  active-high 
        line  17:     "GPIO17"       unused   input  active-high 
        line  18:     "GPIO18"       unused   input  active-high 
        line  19:     "GPIO19"       unused   input  active-high 
        line  20:     "GPIO20"       unused   input  active-high 
        line  21:     "GPIO21"       unused   input  active-high 
        line  22:     "GPIO22"       unused   input  active-high 
        line  23:     "GPIO23"       unused   input  active-high 
        line  24:     "GPIO24"       unused   input  active-high 
        line  25:     "GPIO25"       unused   input  active-high 
        line  26:     "GPIO26"       unused   input  active-high 
        line  27:     "GPIO27"       unused   input  active-high 
        line  28:       "SDA0"       unused   input  active-high 
        line  29:       "SCL0"       unused   input  active-high 
        line  30:         "NC"       unused   input  active-high 
        line  31:    "LAN_RUN"       unused  output  active-high 
        line  32:  "CAM_GPIO1"       unused  output  active-high 
        line  33:         "NC"       unused   input  active-high 
        line  34:         "NC"       unused   input  active-high 
        line  35:  "PWR_LOW_N"        "PWR"   input  active-high [used]
        line  36:         "NC"       unused   input  active-high 
        line  37:         "NC"       unused   input  active-high 
        line  38:  "USB_LIMIT"       unused  output  active-high 
        line  39:         "NC"       unused   input  active-high 
        line  40:   "PWM0_OUT"       unused   input  active-high 
        line  41:  "CAM_GPIO0" "cam1_regulator" output active-high [used]
        line  42:   "SMPS_SCL"       unused  output  active-high 
        line  43:   "SMPS_SDA"       unused   input  active-high 
        line  44:    "ETH_CLK"       unused   input  active-high 
        line  45:   "PWM1_OUT"       unused   input  active-high 
        line  46: "HDMI_HPD_N"       unused   input  active-high 
        line  47: "STATUS_LED"        "ACT"  output  active-high [used]
        line  48:   "SD_CLK_R"       unused   input  active-high 
        line  49:   "SD_CMD_R"       unused   input  active-high 
        line  50: "SD_DATA0_R"       unused   input  active-high 
        line  51: "SD_DATA1_R"       unused   input  active-high 
        line  52: "SD_DATA2_R"       unused   input  active-high 
        line  53: "SD_DATA3_R"       unused   input  active-high 

パーミッション

一般ユーザで使えるようにする。

ファイル /etc/udev/rules.d/60-gpiod.rulesを修正

SUBSYSTEM=="gpio", KERNEL=="gpiochip[0-1]", GROUP="plugdev", MODE="0660"

ファイル /etc/mdev.confに追加

gpiochip([0-9]+)        root:wheel       660

python3-libgpiod

やっぱり、pythonを使いたい!

$ sudo apt install python3-libgpiod
タイトルとURLをコピーしました