From e89c391f4db0d73212f530d04ceb237adf802c30 Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Sun, 13 Dec 2020 08:31:18 +0100 Subject: [PATCH] add setup instructions --- README.md | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d673e13..59d0581 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,52 @@ -# pi-go-gpio -Simple GPIO library for Raspberry Pi in Go + +# Simple GPIO library for Raspberry Pi in Go This module implements a Go module to manipulate the GPIO pins. -Features +## Features + - only uses the sysfs mappings - with a proper setup it can be used without being root - tested on Raspberry Pi 3 / Raspberry Pi 4 - tested with Ubuntu Server 20.10 (Groovy Gorilla) -GPIO +## GPIO -This module uses the pin numbers to identify the GPIO ports. +This module uses the pins to identify the GPIO ports. -This image from [https://pinout.xyz](https://pinout.xyz) helps to find the right pins. +This image from [https://pinout.xyz](https://pinout.xyz) proved helpful to find the right associations. ![Raspberry Pi GPIO Pinout](./doc/img/raspberry-pi-pinout.png) ## Setup -/* -We've whipped up a simple graphical . -Feel free to print, embed, share or hotlink this image and don't forget to credit us! -https://pinout.xyz -*/ +I started with a fresh operating system image. +To enable user access to the gpio via sysfs one has to add these configurations. + +### add group to allow gpio access + +Add a group to be used as owner of the gpio sys file entries + +´´´´shell +~ addgroup gpio +~ adduser ubuntu gpio +´´´´ + +### add configuration to udev rules + +Add a file ´´/etc/udev/rules.d/99-gpio.rules´´ with the following content, reboot your pi +´´´´shell +~ sudo su - +~ cat /etc/udev/rules.d/99-gpio.rules +# +# gpio access for group gpio +# +SUBSYSTEM=="gpio", GROUP="gpio", MODE="0660" +SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\ +chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio;\ +chown -R root:gpio /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio;\ +chown -R root:gpio /sys$devpath && chmod -R 770 /sys$devpath\ +'" +~ reboot now +´´´´