#raspberry-pi #gpio-pin #gpio #raspberry #pi #networking #web-server

bin+lib raspberry-web

Web server for controlling GPIO pins on the Raspberry Pi

1 unstable release

0.1.3 Apr 15, 2019
0.1.2 Mar 10, 2019
0.1.1 Mar 3, 2019
0.1.0 Jan 15, 2019

#1915 in Hardware support

MIT license

54KB
1K SLoC

Rust 1K SLoC // 0.1% comments Python 94 SLoC // 0.3% comments SQL 61 SLoC // 0.1% comments Shell 21 SLoC // 0.3% comments

raspberry-web

Build status Build status Codecov dependency status crates.io

Control GPIO output on Raspberry Pi through a REST service

Run the server and send a GET request to http://localhost:2323/set/level/2/high:

{
    "gpio_id": 2,
    "in_use": 1,
    "gpio_mode": "output",
    "gpio_level": "high",
    "last_change": "2019-02-18 21:19:31.239669"
}

Installation

Prerequisites on Raspbian (apart from Rust):

$ sudo apt-get update && sudo apt-get install build-essential libsqlite3-dev
$ cargo install cargo-deb

Install using cargo deb

$ git clone https://gitlab.com/bogeholm/raspberry-web && cd raspberry_web
$ cargo build --release
$ cargo deb
$ cargo deb --install

Your user will need write permission to /usr/local/raspberry-web unless you only want to run the program as root:

sudo chown -R $(whoami) /usr/local/raspberry-web

Usage

Installation using cargo deb places a binary in /usr/local/bin and a configuration file at /usr/local/raspberry-web/configuration.toml, which should be edited before use.

Say you want to be able to swicth GPIO pins 1,2 and 3 on and off, start with GPIO pins 1 and 2 off (level low) and pin 3 on (level high), you would put the following under the section [gpioconfig]

[gpioconfig]
gpios_in_use = [1, 2, 3]
gpios_mode_output = [1, 2, 3]
gpios_level_low = [1, 2]
gpios_level_low = [3]

Now you can run the server from the command line:

rasbberry-web

You can specify an alternate config file

rasbberry-web --config-file=/path/to/my/awesome/config.toml

You could also use systemd (starting this way will read /usr/local/rasbberry-web/configuration.toml):

sudo systemctl start raspberry-web.service

Repositories

The GitLab repo is mirrored on GitHub.

Dependencies

~58MB
~1M SLoC