gpioscheduler

command module
Version: v0.0.0-...-2e4b27e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2019 License: MIT Imports: 14 Imported by: 0

README

GPIO Scheduler

A simple web interface for maintaining gpio pins and setting schedules for gpio pins. The front end in this case is an example of a sprinkler system. Although this can be used for any general scheduling of gpio pins. NOTE: Re-evaluate the TurnOn and TurnOff methods, the relay that this program was build along side of required the 'On' to output.low on the pin.

Install GO

  • brew install go
or (preferred) then
  • add go to paths
    • e.g.
      • $ export PATH=$PATH:/usr/local/go/bin //added to '/etc/profile' or '$HOME/.profile'
      • $ (optional unless you want to use a directory that's NOT under $HOME/go)export GOPATH=$HOME/go //add to $HOME/.profile or $HOME/.bashrc
      • $ (optional)export PATH=$PATH:$GOPATH/bin //add to $HOME/.profile or $HOME/.bashrc

Install gpioscheduler

  • $ go get -u github.com/peterbradford/gpioscheduler

Running the service

  • $ go run main.go

  • you should now be able to use this curl command and get a result

    • curl -k http://localhost:42069/v1/health
    • curl -k http://localhost:42069/v1/system
    • curl -X POST -k http://localhost:42069/v1/pin -d '{"Id":4}'
    • curl -k http://localhost:42069/v1/turnon/4
    • curl -k http://localhost:42069/v1/turnoff/4
    • curl -X POST -k http://localhost:42069/v1/pin -d '{"Id":4, "Schedules": {"01-21-2019 23:05":2}}'
    • curl -k http://localhost:42069/v1/schedule/4
    • curl -k http://localhost:42069/v1/pin/4
    • curl -X DELETE -k http://localhost:42069/v1/pin/1
    • curl -X DELETE -k http://localhost:42069/v1/schedule/1
  • you should also be able to go to localhost:42069 and see the index.html

For the frontend

just use the following command in the client directory

  • $ ng serve
  • $ ng build --prod=true //if you want to create a deploy-able folder

with ng serve it'll run on localhost, if you build it with ng build it'll run on the host machines local ip address. The backend is set to always run on the host machines local address

GPIO pins

all gpio pins are mapped on the bonnet except pin 26(physical pin 37).
The used gpio pins for this project are mapped like this 

map<bcm, physical>
{
  4: 7
  5: 29
  6: 31 
  12: 32
  13: 33
  16: 36
  17: 11
  18: 12
  19: 35
  20: 38
  21: 40
  22: 15
  23: 16
  24: 18
  25: 22
  27: 13
}

for this project we will use the bcm pin number when talking about a physical pin.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
server
api
pin

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL