1

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

DΦC__WTF
  • 105
  • 1
  • 9

2 Answers2

1

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:

OliWeb on GitHub

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.

Gordon's WiringPi Utility

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:

How to invoke external scripts programs from node js

Community
  • 1
  • 1
T3am5hark
  • 856
  • 6
  • 9
1

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):

Alberto Schiabel
  • 1,049
  • 10
  • 23