Instructables

Web Control of Raspberry Pi GPIO (UPDATED)

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
viggen1 month ago

Awesome, Is it possible to set up a schedual to control pins seconds per day?

winsum10 months ago
Hi drcurzon,
your instructable is very great!

I have only one problem. When i execute the ./GPIOServer.sh, it return two errors:

line 54: /sys/class/gpio/gpio4/direction: File or directory not exist.
line 59: /sys/class/gpio/gpio4/value: File or directory not exist.
GPIO 4 Turned Off
GPIO 17 Turned Off
GPIO 18 Turned Off
GPIO 21 Turned Off
GPIO 22 Turned Off
GPIO 23 Turned Off
GPIO 24 Turned Off
GPIO 25 Turned Off

Why this error?
Very thanks.
Mickey_Boy winsum8 months ago
i have had a similar error, turned out that i had some errors when exporting and selecting direction for the gpio#.
hkusumah1 year ago
awesome tutorial. many thanks for making this instructable
thecank1 year ago
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)  thecank1 year ago
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.
Nechako1 year ago
Thanks for the quick reply, I'll give it a go!! Awesome tutorial.
Nechako1 year ago
Can this be adapted to work with the piface board?
drcurzon (author)  Nechako1 year ago
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.
javilondo1 year ago
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?
rikohz1 year ago
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
Ste7of11 year ago
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)  Ste7of11 year ago
Hi there.
Are you running the script as root?
Many thanks, Dan.
carlvk1 year ago
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)  carlvk1 year ago
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.
(removed by author or community request)
drcurzon (author)  DELETED_zyndatho1 year ago
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.
iscroman2 years ago
Cool project!

I want to try it when I receive my RPi.

Thanks for share.

Regards From México.