Git Product home page Git Product logo

quick2wire-gpio-admin's Introduction

GPIO Admin

A command-line tool to export or unexport the Raspberry Pi's GPIO pins and allow only the user to control then.

Installation

To install the gpio-admin command & manual page, and create the gpio group if it does not already exist, run the following commands from the root of the source tree:

make
sudo make install

To uninstall, run the command:

sudo make uninstall

Getting Started

To access the GPIO pins you must add yourself to the gpio group:

sudo adduser $USER gpio

Then log out and back in again. (Your membership of the gpio group won't take effect until you do.)

You can now export GPIO pins and use them without having to log in as root or use the sudo command.

% gpio-admin export 22
% cat /sys/devices/virtual/gpio/gpio22/value
0
% echo out > /sys/devices/virtual/gpio/gpio22/direction
% echo 1 > /sys/devices/virtual/gpio/gpio22/value

When finished with a pin, unexport it again:

% gpio-admin unexport 22

GPIO Pin Identifiers

The gpio-admin command works with the GPIO identifiers defined by the SOC, not Raspberry Pi header pin numbers or the GPIO numbers assigned to header pins by the Raspberry Pi documentation.

The example above uses SOC GPIO 22, which corresponds to header pin 8 on the Raspberry Pi, and that pin is named GPIO 3 in the Raspberry Pi documentation.

All very confusing!

We provide higher level APIs that map between the pin identifiers that users understand and the identifiers defined by the SOC, and use gpio-admin behind the scenes to export/unexport GPIO pins as required.

Enabling the Pi's Pull Up and Pull Down Resistors

The Pi supports pull up and pull down resistors for each GPIO pin. To enable this add either "pullup" or "pulldown" as a 3rd parameter. Assumming that pin 17 is floating:

% gpio-admin export 17 pullup
% cat /sys/class/gpio/gpio17/value
1
% gpio-admin unexport 17
% gpio-admin export 17 pulldown
% cat /sys/class/gpio/gpio17/value
0

More Information

Usage instructions are installed as a man page, and so can be read with the command:

man gpio-admin

Copyright & License

Copyright © 2012 Quick2Wire Ltd. http://quick2wire.com/

See LICENSE.md for license information.

quick2wire-gpio-admin's People

Contributors

npryce avatar romilly avatar gnarlie avatar

Watchers

James Cloos avatar Lee McKay avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.