Cheap, Effective and Modern Home Automation
Step 1: What You Need
Picture of What You Need
We need :
4 Array Relay Module
Step 2: Wiring Picture of Wiring
Picture of Wiring
Picture of Wiring
We need to connect our Raspberry and the module .We will get the 5V from the Raspberry (not very recommended but its easy ) .So lets begin :
PI GPIO | Relay module
Pin 4 ---------VCC
Pin 6 ---------GND
Pin 8 ----------IN4
Pin 10 ---------IN3
Pin 11 ---------IN2
Pin 12 ---------IN1
Step 3: Testing
Picture of Testing
Picture of Testing
Now we need to start the raspberry and to connect to the power supply and connect to it over FTP with Filezilla or start it on monitor . Next download and put the test_relay.py file in the main dir (home/pi).Then start the python script by typing :
sudo python test_relay.py
If leds start flashing from IN1 to IN4 and shutdown from IN4 to IN1 then everything is okey and the wiring is like currect .We can move to the next step .
The relay boards are powered by 5v and the relays are triggered by taking the input pin to ground. Since the Raspberry Pi's GPIO pins output 3.3v I used a set of transistors to take the relay pins to ground.
So when you are setting the GPIO output value:
1) 0 the relay starts ;
2) 1 the relay stops .
Add TipAsk QuestionCommentDownload
Step 4: Installing Apache and Php
We will need them for the server part .Helpfull link.
To install apache2 we need to run :
sudo apt-get install apache2 -y
To test the webserver we can you on the raspberry browser
(raspberry ip address) .Type
to get the current IP .
Next install PHP5 module for APACHE :
sudo apt-get install php5 libapache2-mod-php5 -y
And remove index.html file :
sudo rm index.html
The next thing is to navigate to the default directory:
For Raspbian Wheezy is /var/www ,
For Rspbian Jessie is /var/www/html
So we type :
And this will output :
drwxr-xr-x 2 root root 4096 Jan 8 01:29 .
drwxr-xr-x 12 root root 4096 Jan 8 01:28 ..
-rw-r--r-- 1 root root 177 Jan 8 01:29 index.html
We need to change the permission if we want to upload or modify files :
sudo chown pi: index.html
Delete the index.html file from the dir.
Step 5: Uploading the Needed Files for Your Web App
Picture of Uploading the Needed Files for Your Web App
You need to download the .rar file , extract it and copy the files with Filezilla to the main dir of Raspberry home/pi and to the var/www. For pasting the files into var/www you need to set a permision .
When you are done coping the files , just go to your browser , type RaspberryIP/index.html (ex: 192.168.1.23/index.html) and the webpage will be opened .And also you can test it and remotely control the relays from any device that is connected to your local network(router) .
Enable sudo for APACHE
User_Alias APACHE = www-data
Cmnd_Alias FIREWALL = /usr/bin/python
APACHE ALL = (ALL) NOPASSWD: FIREWALL
PiRelay.zip PiRelay.zip Download
Step 6: How It Works Picture of How It Works
I will explain it shortly. If you want to get to more details you can see the project in github.
When we click on the button , the ajax request has been called and the php file from it is called . From the php we execute a python script file with some params . The python script return us json converted array , which we pass to the php and the php passes it to html file .We can go only in the one way but if we want to reload the page we need in what position the relays are . The other point is if we dont do it that way there is no feedback and we cant see what is happening .
The symbols in basic Las Vegas slot machines include fruit like plums, cherries and lemons. Modern video slots use a range symbols to match their theme and graphics. A payline refers to the to the} variety of possibilities you have to to|you must} win in a particular slot sport. Matching symbols on a single payline can create a successful mixture. Online 카지노 casinos will verify your id earlier than you withdraw. This is to protect underage gamers and stop money laundering.
Postar um comentário