This server is implemented with Node.js, and Python.
First, make sure you have Node.js, and npm installed on your pi:
sudo apt-get update
sudo apt-get upgrade
sudo wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb
node -v #check if node is installed successfully
Next, clone this repository and install all the dependencies:
npm install
Modify settings in pi.config if you need to, and start the server with the following command:
sudo node app
Note that the server needs to run as super user because it needs permissions to perform I/O operations on IO pins.
GET /rangeSensor
This method needs no parameters.
GET /toggleIOPin
Calling this method will toggle a specific GPIO pin on the raspberry pi.
Parameters:
pin
: A number to specify the GPIO Pin you want to toggle on your Pi.- Eg.
pin=3
toggles GPIO3 on/off.
- Eg.
POST /motionHook
Add a new web hook that triggers when the motion sensor detects a motion.
Parameters:
address
: A http address the pi will send a get request to when motion is detected.- Eg.
address=http://127.0.0.1/callback
- Eg.
DELETE /motionHook
Remove a web hook for the motion sensor on the raspberry.
Parameters:
address
: A http address of the web hook you want to remove.- Eg.
address=http://127.0.0.1/callback
- Eg.