I want to communicate with my raspberry pi, through my webserver. I want to use a web interface on my server, with which I can control an LED on my PI. Can I use "node js" for this? or does anyone have a good idea or examples?
regards
I want to communicate with my raspberry pi, through my webserver. I want to use a web interface on my server, with which I can control an LED on my PI. Can I use "node js" for this? or does anyone have a good idea or examples?
regards
You can indeed use just about any web server to communicate with the pi and thereby control its GPIO pins.
I wrote a web server specifically to interface with the pi's GPIO capabilities complete with utilities and examples if you want to try it out. It's a very lightweight native-code (C++) web server that you can use to control your LEDs (or what have you) with about 5 mins of setup:
You can install it using git with:
sudo git clone https://github.com/m2ware/OliWeb.git
You could also install just about any other web server out there (Nginx, Node.JS, take your pick) and set up CGIs to call command-line utilities to drive the LED pins. Gordon's WiringPi utilities are easy to use and install - installation and usage instructions are below.
Each web server will have its own particulars in terms of invoking command line interfaces via CGI. If you're interested in NodeJS specifically, this describes how to invoke command-line functionality from Node:
I know it is a little bit late, although for those who may be still interested I've recently developed a school project which does exactly this job.
I've used WebSocket and GPIO handling.
Here's the repo for the client: https://github.com/jkomyno/material-led-controller/
Here's the one for the server (you gotta put this on your RPI):