Please Note:
This Instructable is now depreciated.
Click here for the updated, much improved, version.

Hi there,
This will hopefully show you how to control electronics across the internet using your Raspberry Pi.
It's not the best way to do it, and soon I will update this with a way to use MySQL to do the same thing.

Here's a link to YouTube showing it in action: http://www.youtube.com/watch?v=OCZlfAFcm7Q

For this, please ensure that you have apache with php running on your Raspberry Pi, Instructions can be found here.

Also, it would be a good idea to read my previous instructable on general GPIO control, which can be found here.

Step 1: Overview + Warning

This is not the best way of doing this, and I hope to update this soon with a MySQL solution.
Until then, I'd recommend keeping this to your local network (not over the internet yet).
However, there shouldn't be any issues, it's just a warning. :D

This will (at the moment) allow you to control your GPIO pins via a web interface.
The program running on your Raspberry Pi checks to see if a file exists, if it does - it turns the output on, otherwise it turns it off. All the web interface does (at the moment) is to either create or delete this file.
<p>Hii, I have a doubt. My main project is home automation using internet in which i have to control speed of fan at five different levels from internet. I designed a web-page and kept 5 buttons in it. I am able to send signal to raspberry pi when i press any one button. Now my problem is what should i write additionally and also what task should i do so that i can interpret the incoming signal to pi and accordingly generate square wave pulses from my GPIO pins of pi.</p><p>THANKS IN ADVANCE</p>
<p>where is the <strong>gpio.sh text ? i dont see for download , please help me</strong></p>
hi great tutorial , just what I`ve looking for . I do have one problem <br>julian@GridCamera:~/PiStuff/php_2_gpio$ ./gpioCheck.sh <br>Please enter a wait time <br>1 <br>': not a valid identifieread: `waitTime <br>Please enter GPIO number <br>26 <br>': not a valid identifieread: `pin <br>./gpioCheck.sh: line 24: syntax error near unexpected token `fi' <br>./gpioCheck.sh: line 24: `fi' <br> <br>I get the above error. Not clued up on sh any ideas. <br> <br>Julian
Hi, first of all a great tutorial, but I'm having a problem since I'm a beginner with raspberry. I followed all the steps but something is wrong. . <br>When I open the web page in my browser I don't see anything. <br>http://www.mediafire.com/view/6308724smksg08c/Capture.JPG <br> <br>I tested the php5 and apache server and they both work. <br>http://www.mediafire.com/view/u19wb3o5nwb9to9/Capture2.JPG <br> <br>Please help.
hi, i have a problem. <br>i am beginner for Raspberry, shell script and web. <br> <br>1. when i run the web, and i press &quot;turn on&quot; button. the browser say &quot;can't open file&quot; <br>2. when i run gpioChek.sh, the command exit is always &quot;turn on&quot; although i press &quot;turn off&quot; button on a browser. <br>Can anyone help me to be able to run like the one in the video http://www.youtube.com/watch?v=OCZlfAFcm7Q <br>many thanks. mima
Oh just read the overview and got it now thanks xD ill try it latter...
Hi, dont know if im wronge but isn't there 3 files in this project? <br>gpio.php (webpage) <br>gpiocheck.sh (bash script running on server) <br>gpio.txt (txt file were the status of the pin is stored) <br> <br>do you have the code for the .txt if there is any at all? <br> <br>Thanks. <br>
Hello, I have a problem<br> <br> 1) I create a php file with the given code (gpio.txt) then I placed in var / www<br> 2) I create a txt file with the given code (gpioCheck.txt) then I placed in a directory (the first available: home)<br> 3) I logged in as root via Putty and i placed in the home directory (cd / home)<br> 4) I have run this commands :<br> <br> -&quot;mv gpioCheck.txt gpioCheck.sh&quot;<br> -&quot;chmod +x gpioCheck.sh&quot;<br> -&quot;./gpioCheck.sh&quot;<br> <br> 5) and this is what I get: <a href="http://hpics.li/4b247d7" rel="nofollow">http://hpics.li/4b247d7</a><br> <br> I don't Understand !! What's the Problem ??? Thanks
Try changing the wait time to 1. <br>Many thanks. Dan.
the problem does'nt looks to be here : http://hpics.li/c8972c1 <br>I am not a specialist, but there seems to be a problem in the script &quot;gpioCheck&quot;, <br> <br>Here is the code I downloaded and copy: <br> <br>&quot;echo &quot;Please enter a wait time&quot; <br>read waitTime <br>echo &quot;Please enter GPIO number&quot; <br>read pin <br>if [ &quot;$pin&quot; != &quot;4&quot; ] &amp;&amp; [ &quot;$pin&quot; != &quot;17&quot; ] &amp;&amp; [ &quot;$pin&quot; != &quot;18&quot; ] &amp;&amp; [ &quot;$pin&quot; != &quot;21&quot; ] &amp;&amp; [ &quot;$pin&quot; != &quot;22&quot; ] &amp;&amp; [ &quot;$pin&quot; != &quot;23&quot; ] &amp;&amp; [ &quot;$pin&quot; != &quot;24&quot; ] &amp;&amp; [ &quot;$pin&quot; != &quot;25&quot; ]; then <br>echo &quot;Pin error - GPIO number doesn't exist&quot; <br>else <br>echo &quot;$pin&quot; &gt; /sys/class/gpio/export <br>echo &quot;out&quot; &gt; /sys/class/gpio/gpio$pin/direction <br>while : <br>do <br> <br> if [ -f /var/www/gpio.txt ] <br> then <br> echo &quot;Turn GPIO on&quot; <br> echo &quot;1&quot; &gt; /sys/class/gpio/gpio$pin/value <br> else <br> echo &quot;Turn GPIO off&quot; <br> echo &quot;0&quot; &gt; /sys/class/gpio/gpio$pin/value <br> fi <br> sleep $waitTime <br>done <br> <br>fi&quot;
the browser says can't open file <br> <br> terminal says write error: Device or resource busy <br>how to fix it please reply soon........ <br>
Thank you for this instructable. I'm wondering if it is possible to somehow execute Python (.py) scripts through the web-server. I'm kind a new for Linux and started working on Raspberry pi 2 weeks ago. I have 7 Python programs which are driving servo motor by generating different pulses. I just want to do a simple web page with 7 buttons. When you press one of the buttons, Python script should start executing. Any help and comments would be appreciated.
I get an error when i click turn on . It says &quot;cant open file&quot;
Hi, <br> <br> I am having problems uderstanding this line of code from gpioCheck.txt <br> <br>if [ -f /var/www/gpio.txt ] <br> <br>I understand that it is checking to see if the file gpio.txt is there or not, it's the -f part I can't seem to find on the internet. All I find for python language is os.path.exists or something similar to check if the file exists not -f. <br> <br>Thanks in advance. You have really helped me out with this instructable. Thank you for shareing.
Would you believe it. This is not python language but shell script language (so many different languages to learn!) Found it 5 mins after posting this question. <br> <br>http://www.freeos.com/guides/lsst/ch03sec02.html <br> <br>Shell also test for file and directory types <br> <br>Test Meaning <br>-s file Non empty file <br>-f file Is File exist or normal file and not a directory <br>-d dir Is Directory exist and not a file <br>-w file Is writeable file <br>-r file Is read-only file <br>-x file Is file is executable <br> <br>Once again thanks for the tutorial. <br> <br>Best regards Rogerramjetrdn <br>
Thanks for the great tutorials. I am getting the following error when running the script: <br>Turn GPIO on <br>./gpioCheck.sh: line 16: /sys/class/gpio/gpio25/value: Permission denied <br> <br>Can you please help with what I might be doing wrong <br>Thanks
Sorry for the lack of concentration. All I needed to do was run the script as root. <br> <br>I'm new to Linux so learning as I go. <br> <br>Thanks again for the great tutorial
No Problem, glad you sorted it out :D
See my Setup here: <a href="http://langeder.no-ip.org/cms/index.php?p=raspberry-pi-server" rel="nofollow">http://langeder.no-ip.org/cms/index.php?p=raspberry-pi-server</a>
So ready for my Pi to get in... Thanks for the ible!

About This Instructable


93 favorites


Bio: Hi there, I'm an engineering apprentice with a passion for computing.
More by drcurzon:
Add instructable to: