Skip to content
A simple, pure erlang, raspberry pi user-space gpio library
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

#πGPIO A simple, pure erlang implementation of a module for Raspberry Pi's General Purpose Input/Output (GPIO), using the standard Linux kernel interface for user-space, sysfs, available at /sys/class/gpio/.

This module was created to try robotics on raspberry Pi using erlang and have not tests, error checking or fancy outputs. It was created for my own use and I'm releasing as it may be useful for someone.
I hope you enjoy!


  • Raspbian GNU/Linux;
  • erlang 17+, apt-get install erlang solve it;
  • root, to access "/sys/class/gpio/" files.
  • rebar, to speed things up (wget && chmod u+x rebar)


on projects

  • add to dependencies of your rebar.config:
{deps, [
    {gpio, "", {git, "git://"}},
    ... % other dependencies goes here
  • then just compile:
$ rebar compile


$ sudo erl
Erlang/OTP 17 [erts-6.2] [source] [async-threads:10] [kernel-poll:false]

Eshell V6.2  (abort with ^G)
1> c(gpio).
2> L0 = gpio:init(23, out).
3> L1 = gpio:init(22, in).
4> gpio:write(L0, 1).
5> gpio:read(L1).


  • init(Pin, Direction) Initialize a pin as output or input, according to Direction(an atom). It returns a Reference to Pin.
  • init(Pin) A shortcut to initialize pin as output. It, also, returns a Reference to Pin.
  • stop(Ref) Stop using and release th pin referenced as Ref. It returns an atom, ok.
  • write(Ref, Val) Writes Val, 1 or 0, into the pin initialized and referenced as Ref.
  • read(Ref) Reads a value(1 or 0) from pin referenced as Ref and returns it.

For the official erlang-style documentation, run:

$ erl -noshell -run edoc_run application 'gpio' '"."' '[]'

Tested on

  • Erlang/OTP 17 erts-6.2 in GNU/Linux Raspian 8.0 (jessie) kernel 4.1.19+ armv61 on Raspberry B+
  • Erlang R15B01 erts-5.9.1 in GNU/Linux Raspian 7 (wheezy) kernel 4.1.13+ armv6l on Raspberry B.


MIT License © 2015-2016 Paolo Oliveira.

You can’t perform that action at this time.