Raspberry PI IOT Server with Node JS LED Control (Express.JS + ejs) Reviewed by Momizat on . [box type="info" color="#fff" bg="#4494CD" icon="https://www.myelectronicslab.com/wp-content/uploads/2017/07/hand_right1600.png" font="verdana" fontsize="16"]In [box type="info" color="#fff" bg="#4494CD" icon="https://www.myelectronicslab.com/wp-content/uploads/2017/07/hand_right1600.png" font="verdana" fontsize="16"]In Rating: 0
You Are Here: Home » IOT » Raspberry PI IOT Server with Node JS LED Control (Express.JS + ejs)

Raspberry PI IOT Server with Node JS LED Control (Express.JS + ejs)





Introduction:

Hello Friends,

This tutorial will guide you to step by step, making one local server in Node JS and Control LED from remotely within your local network.

NOTE: If you think, You don’t Know “NodeJS” and new to electronics, Don’t Panic, I will guide you. Trust me, its supper simple. Just make sure you follow till end of this tutorial.

If you don’t want to use Node JS , you can also check my previous tutorial on controlling Raspberry PI GPIO using C.

 

Components You Need:

Circuit Diagram:

circuit-diagram-raspberry-pi-node-js-server-led-control

GPIO 7 of Raspberry Pi is going to LED positive terminal(You can add one 330E Resistance in series). and GND of raspberry Pi going to LED Cathode.

Software Configuration:(Node Js Installation Steps For Raspberry PI)

As we are going to write code in Node JS. You have to install Node JS and NPM in your raspberry PI. Here are steps to do that. Click Here for Node JS Installation Steps

Or

Follow Bellow Steps:

First update the local packages and then install node js using following commands.

Download and Run Code:

  • Open Raspberry Pi Terminal. If you are doing ssh(remote Access) open Putty and login to raspberry PI.
  • Create on Directory using following command.

  • Go inside that directory using cd command.

  • Then we need git client to download the code from git server.(If you already have git client, skip this step.)

  • Download the code using following command.

  • A New directory will be created. Go Inside that directory using cd command.
  • Inside the project directory, you have to run following command to install all library of node Js. use following command.

  • Once all installation will is done, you have to run one more command to start the local server and control the LED.

  • You will see one server message on the console , telling server is started at port 3000.
  • Now Go to your browser and open raspberry pi URL along with Port Number.which looks something like http://192.168.1.6:3000 (IP may change in your case.)
  • Now you will see something like this.

 raspberry pi node js server with led iot control

Conclusion:

Now your turn, add some value to this code, create something awesome. If you create this project or something cool out of this, Please share with me, I will be happy to see and share that.

Hope this simple Node JS server for raspberry pi is useful for you. In case you face any problem during installation and run of this server, don’t hesitate to ask in comment section below.

 

Thanks

Keep Learning, Keep Sharing.

 

About The Author

I am a maker, who loves to think, hack and build new electronics stuff, I always find time to document , share my knowledge with others. I am graduate in BTech(Electronics and Communication Engineering).

Number of Entries : 40
Scroll to top