Top Banner
Home automation with Raspberry PI & smarthome app By Mayank Singh https://github.com/mayankmania/smarthome
11

smarthome

Apr 15, 2017

Download

Documents

Mayank Singh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: smarthome

Home automation with Raspberry PI &

smarthome appBy Mayank Singh

https://github.com/mayankmania/smarthome

Page 2: smarthome

Home automation with Raspberry PI 3, Node JS, Raspbian OS & ms-gpio.js• Setup• Hardware• Software

• Access Rights

• Running The Project• Accessing the Application

Page 3: smarthome

Setup : Hardware• 1.Raspberry Pi 3 model B, with at least 16gb memory card which must be preloaded with Raspbian

OS. For installing Raspbian OS on memory card, you can refer to this website• 2.5V 10A 2 Channel Relay Module • Screenshot 5v 2 Channel Relay Switch • Relay switch shown in the above picture is a two channel relay module, only two electrical devices

can be controlled with this. For controlling more devices, you can go for 4,6 or 8 channel relay switch

• Relay switch shown in the above picture is a two channel relay module, only two electrical devices can be controlled with this. For controlling more devices, you can go for 4,6 or 8 channel relay switch

Page 4: smarthome

Hardware• Circuit creation, each device is controlled by set of GPIO pins & relay

switch channel. Depending upon the number of electrical devices we want to control, those many number of GPIO pin must be connected to a channel/input on a relay switch. Next step is to create a circuit between relay switch and electrical device, this can be done by keeping the live current passing as in input, with output coming from relay switch to the electrical device.

Page 5: smarthome

Hardware Circuit Diagram

Please note, how we have created circuit between relay switch and an electrical appliance. You need to ensure that the live current wire from the plug goes directly into the relay switch Common/Middle electrical contact; and it comes out either from Normally Connected or Normally Open electrical contact, but not both at the same time. Also neutral wire from the plug must be directly connected to the electrical appliance.

Page 6: smarthome

GPIO Pin Mapping• Note: While interacting with the GPIO pin, Raspberry Pi(BOARD/physical)

pin number must be passed. Please see this page for more details• Each device is controlled by a specific GPIO pin, hence configuration of the

electrical device and pin mapping must be done in advance• Current application shows a demo which can work with 4 devices, but it can

be extended to more appliances• GPIO pin mapping of 4 devices are given as follows:

• Physical Pin 15 maps to GPIO22 => fan• Physical Pin 16 maps to GPIO23 => bulb• Physical Pin 18 maps to GPIO24 => washer• Physical Pin 19 maps to GPIO10 => tv

Page 7: smarthome

GPIO Pin Mapping

As shown in the above picture, we are always going to control the GPIO by using it physical number highlighted in the middle using circle

Page 8: smarthome

Setup : Software• Node.js • MS-GPIO node module• HTML5/Bootstrap• Linux/Rasbian• Putty, can be used for remotely connecting terminal session with

Raspberry PI• Raspberry PI Static IP : Assign static IP 192.168.0.7 to the Raspberry PI

device. smarthome application can then be accessed with the fixed IP from any device within LAN

Page 9: smarthome

Access Rights• For working with this Raspberry Pi device user must have Super/root

user privileges

Page 10: smarthome

Running the project1. Start your Raspberry PI device2. To work with Raspberry PI , you need to have a super user access, sudo -i command can

be used for the same3. Navigate to the Desktop folder, clone/download this project in your Raspberry PI device4. Run the following command in the order given.

• Navigate to the smarthome foldercd /home/pi/Desktop/smarthome• Run below command to install npm packages required for this projectnpm install• Run below command to run the applicationnode index.js

If everything works well, your application must be hosted locally on 9000 port

Page 11: smarthome

Accessing your smarthome application• You can access smarthome application from any device(mobile/PC) which is connected to same

LAN as Raspberry device, just enter http://192.168.0.7:9000 in the browser. It should present a HTML based UI, which will provide you a list of devices along with their current status(running/stopped). You can now control each device by clicking on the play and stop button provided in front of each device

• smarthome application view :Mobile View Desktop View