Introduction: Home Automation Using Raspberry Pi 3 and Node-RED

Required Materials:
1.Raspberry Pi 3
2.Relay Module
3.Jumper Wires

For More Info Refer:

Step 1: Installing Node Red

Node-RED is a visual tool for wiring the Internet of Things that can be run on a Raspberry Pi and allows for rapid prototyping of projects. Before I start, I want to clear something: I am new here so it might possible that I have made mistakes. So just ignore it.

Set up Raspberry Pi on the network and update the distribution. You can run the following commands in terminal for that:

sudo rpi-update
sudo reboot
After reboot execute following commands:

sudo apt-get update
sudo apt-get upgrade
At the end of the project, final user interface of this project will be looking like the following:

Step 2: Installing Node-Red

This application runs in web browser, so you don't need to install any extra application to play with it and you can run it from any smart phone, tablet or from a PC which has a web browser. And as for what this project is concerned, you can automate your home within your home network only. You can extend functionality of the system but I am not going to explain it in this project.

For this project, first you will need to set up Node-RED on a Raspberry Pi 2.

Installing Node-RED on Raspberry Pi
There are two ways for this:

There is pre-installed Node-RED in the November 2015 Raspbian Jessie image. Go to: Menu->Programming->Node-RED.
Or you can install it manually. A very good documentation available for that and you can find it here.
Running Node-RED
After setting everything up, the next step is to run Node-RED. You can run it from the Menu or by the following command in terminal:

node-red-start
node-red-stop (to stop Node-RED)
If you want to work on the Raspberry Pi desktop, then open the web browser and enter the address you may find as shown in following image after running Node-RED:

Step 3: Opening Node-Red

Or the second option (much better than working on local host) is to open web browser in any other PC (faster than Raspberry Pi) connected to your home network and enter the address as you can find shown in following picture.

I have used the second option. Open the web browser and enter the address of your Raspberry Pi, in my case it is: 192.168.1.12:1880

If everything is correct then you will find following result:

As you can see in the left side there are many different nodes, and I am going to use some of them for this project. Just Drag and Drop to use them.

Step 4: Installing Extra Nodes

extra nodes to your Raspberry Pi and it is very simple, just enter following commands in terminal:

cd ~/.node-red
npm install node-red-contrib-gpio (Documentation)
npm install node-red-contrib-ui (Documentation)
You can find many other nodes and documentation here (not required for this project). After running these commands, I recommend to stop and restart the Node-RED so it can update the node list.

Step 5: Hareware Setup

Hardware Set Up
Connect the hardware components to proper pins as you defined in Node-RED. Check schematic section for circuit diagram.

Output
If you have done everything correct then you will find the result as in this

Step 6: