Skip to content
Go to file
Cannot retrieve contributors at this time
175 lines (94 sloc) 3.51 KB


Proof of Concept service running on a Raspberry Pi that can control LED's via GPIO and I2C protocol.

Stages of Development (Milestones if you prefer)

Stage One

A Phoenix service installed and responding to /ping endpoint

Stage Two

Service blinks an LED while running

Use Periodic Actor (example)

Use elixir_ale for GPIO functions

Stage Three

Endpoint can manipulate a second LED


on / off in body (some structured data)

Stage Four

Endpoint can cycle between various patterns on Pixel Matrix

HTTP POST /matrix

{ pattern: n }

Stage Five

Endpoint accepts 8x8 matrix to determine set display state

HTTP POST /matrix/raw

[ [ 1, 1, 1, 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 1, 1, 1, 1 ]]

Getting it to work

Setting up the Raspberry Pi

Install the things

Erlang and Elixir

sudo vi /etc/apt/sources.list

append the following to the file:

deb wheezy contrib

Import the public key:

sudo apt-key add erlang_solutions.asc && rm erlang_solutions.asc


sudo apt-get update
sudo apt-get install -y erlang
sudo apt-get install -y elixir


Create a file called in /etc/profile.d/ and add the following content


export MIX_ENV=prod

This will set up the environment variables used by the service.


The service must be built using the same OS as that on which it will run (Raspbian in the default case).

  1. ssh to the Raspberry Pi

  2. Clone the repo from github:

    git clone

  3. Switch to the firewerx directory:

    cd firewerx

  4. Get the dependencies:

    mix deps.get

  5. Compile the dependencies:

    mix deps.compile

  6. Create the release:

    mix release



Follow these directions for actual release. The "Run" instructions below can be used locally or for testing.

  1. Copy the systemd configuration into place:

    sudo cp scripts/firewerx.service /lib/systemd/system

  2. Enable the service in systemd:

sudo systemctl enable firewerx.service

  1. Start the service:

sudo systemctl start firewerx.service

If all this succeeds the service will start when the Rasberry Pi is rebooted.


PORT=808 rel/firewerx/bin/firewerx start

confirm the service is running...

rel/firewerx/bin/firewerx ping should return "pong"

curl http://localhost:808/ping should return "pong"

also ensure the service can be called from a remote host.



curl http://<raspberry-pi-ip>:8088/ping

Get the current state of the LED:

curl http://<raspberry-pi-ip>:8088/led

Turn the LED on:

curl -X POST -d '{"value":0}' -H "Content-Type: application/json" http://<raspberry-pi-ip>:8088/led

Turn the LED off:

curl -X POST -d '{"value":1}' -H "Content-Type: application/json" http://<raspberry-pi-ip>:8088/led


There is a demo script in the scripts/ directory that exercises the service. It will run until you cancel execution with Ctrl + C.

To execute it:


Enjoy the show!

You can’t perform that action at this time.