Crates.io | raspberry-web |
lib.rs | raspberry-web |
version | 0.1.3 |
source | src |
created_at | 2019-01-15 20:33:56.062357 |
updated_at | 2019-04-15 18:50:34.969148 |
description | Web server for controlling GPIO pins on the Raspberry Pi |
homepage | |
repository | https://github.com/bogeholm/raspberry-web |
max_upload_size | |
id | 108772 |
size | 102,871 |
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"
}
Prerequisites on Raspbian (apart from Rust):
$ sudo apt-get update && sudo apt-get install build-essential libsqlite3-dev
$ cargo install cargo-deb
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
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