Web Control of Raspberry Pi GPIO (UPDATED)

 by drcurzon

Step 7: Overview

This concludes the Instructable.

For security reasons, you should now disable the root account

To keep updated on the latest releases, or to report a bug / glitch - go to http://code.google.com/p/raspberrypi-gpio/

All comments and criticisms are welcome.
Hope this helps, Daniel.
 
Remove these adsRemove these ads by Signing Up
thecank says: Apr 6, 2013. 1:19 PM
Great tutorial!! I finally got this working as well as my wireless adapter!!
I have a question that I have not found the answer to yet and I'm not all that familiar with PHP.

When I log on to the Control.PHP page with an iPhone, the page is very small and I have to zoom in. I also have to re-zoom every time I push a button.
Is there a way to set the screen resolution for an iPhone or other mobile device in the PHP script?
Again, thanks so much. This is so much fun!
drcurzon (author) in reply to thecankApr 6, 2013. 1:21 PM
Hi there,
I believe that has to be set in the HTML and CSS of the page.
Sorry I can't be of more help.
Thanks, Dan.
Nechako says: Mar 20, 2013. 6:49 AM
Thanks for the quick reply, I'll give it a go!! Awesome tutorial.
Nechako says: Mar 18, 2013. 6:44 PM
Can this be adapted to work with the piface board?
drcurzon (author) in reply to NechakoMar 19, 2013. 2:50 AM
Hi there.
I think that the piface board is a solution in its own right, however it probably could be controlled by the scripts if you really wanted.
Many thanks, Dan.
javilondo says: Mar 16, 2013. 2:11 AM
Thanks a lot for this great instructable!
This information will be pretty usefull for mi proyect:
I am building a clock for the city hall in my town "Jalos" (in Mexico) that is able to configure via the web for people with privileges to schedule it in the departament of social communication. I built the mechanism and its controller that connects to the RPi. I use a DS1302 with its backup battery to avoid errors by power outage. Three actuators, which control the motor of hand's axis, the bell quarters and the bell of hours. This machine will play songs of my town at each hour with an amplifier, for this i use the program mpg123 that plays ogg and mp3 files.
Just need to use reading encoders that tell me the position of the hands.
I wonder how can I scan/read the pins of GPIO as inputs?
rikohz says: Feb 10, 2013. 7:35 PM
Hi, thanks a lot for this tutorial, it worked perfectly. I made a few changes to make it work as a service and reduce the number of SQL queries. I used a Python script for that with a crontab, i chose in this case to have an update every 2 seconds. Here is the script:

### Script Python ###

#!usr/bin/python
from time import sleep;
import RPi.GPIO as GPIO;
import MySQLdb

GPIO.setmode(GPIO.BCM)
conn = MySQLdb.connect('localhost','user','password','table_name');

while True:
    curs = conn.cursor();
    result = curs.execute("select * from pinStatus");
    result = curs.fetchall()
    for row in result:
      pinNumber = int(row[1])
      pinStatus = True if int(row[2]) == 1 else False
      GPIO.setup(pinNumber, GPIO.OUT)
      GPIO.output(pinNumber, pinStatus)
    curs.close()
    sleep(2)

##############

And the crontab looks like:
@reboot /home/toto/script.py
(@reboot means that the following script will be launch everytime the computer is started)

Any comments or advice are welcome
Ste7of1 says: Jan 31, 2013. 4:28 PM
I am having a problem and can't figure where I went astray. When I run the script (GPIOServer.sh) I get an error /sys/class/gpio/export: permission denied. This repreats for each pin assignment. I assum I have an access problem in the db but my username and password seem correct. Any direction Appreciated.
Steve
drcurzon (author) in reply to Ste7of1Feb 1, 2013. 6:26 AM
Hi there.
Are you running the script as root?
Many thanks, Dan.
carlvk says: Oct 3, 2012. 3:12 AM
Great instructible. thank you.
I know this is a month old now but I was wondering were to look to adjust the code for the buttons
I want to run two gpio pins at once and also be able to hold the button on and off when released (onmousedown or touch screen equivalent).
all help gratefully recieved
drcurzon (author) in reply to carlvkOct 3, 2012. 11:28 PM
Hi there. "GPIOserver.sh" and the "index.php" files are the ones to modify.
If you only want to lock buttons on, etc, then edit the "index.php" file only.
Daniel.
DELETED_zyndatho says: Aug 23, 2012. 10:17 AM
(removed by author or community request)
drcurzon (author) in reply to DELETED_zyndathoAug 23, 2012. 11:32 AM
Hi there,
There are UART pins on the raspberry Pi that I've had a lot of fun with,
(PLEASE NOTE these are UART not computer serial (so around 3v signal)).

http://cdn.instructables.com/FJA/5B1M/H2WERJ0U/FJA5B1MH2WERJ0U.LARGE.jpg

Pin 8 is the Transmit, and Pin 10 is the Receive pin.

As for the application, I used minicom on the Raspberry Pi.

Many thanks, Daniel.
iscroman says: Jul 17, 2012. 12:34 PM
Cool project!

I want to try it when I receive my RPi.

Thanks for share.

Regards From México.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!