gabrielnvg / gpio-nodejs-api

Control your Raspberry Pi's GPIO via HTTP requests.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation

On project's directory, run:

$ npm install

Usage

Running the server

On project's directory, run:

$ npm start

It will be running at http://localhost:3001/

Reading all GPIO ports

Go to http://localhost:3001/readall

Reading a specific pin state

On the URL, write a GPIO pin number (pin's name number, not physical number).

Writing a value to a pin

On the URL, write a GPIO pin's number (pin's name number, not physical number), its direction (1 for INPUT or 0 for OUTPUT) and its value (1 for HIGH or 0 for LOW).

Observations

  • The port 3001 was chosen so it would not conflict with other Node.js apps such as Amazon's Alexa on Raspberry pi.
  • This project uses Node.js' child_process to execute shell commands, so be sure to check if your user has GPIO permission.

About

Control your Raspberry Pi's GPIO via HTTP requests.


Languages

Language:JavaScript 100.0%