Springen naar inhoud


How To Web Control Of Raspberry Pi Gpio?

Web Control GPIO

  • Log in a.u.b. om te beantwoorden
Geen reacties in dit onderwerp

#1 pascalbianca



  • Webmaster
  • 4382 berichten
    Laatst bezocht 12 jan 2024 08:50
  • LocatieSusteren, Nederland, Midden Limburg.

Geplaatst op 08 december 2012 - 11:37

First of all this tutorial comes from drcurzon but i did some changes and downloads to make this tutorial complete.
The files were no longer to download, so I had to search the internet to get them compleet.

This webcontrol is much more secure and could easily be used across the internet with very few security concerns, because you must sign in with a login and password to get the buttons to respond on your command.

This is how the controls look like, its just a standard layout so you can do with it what you want ;)
Bijlage  layoutexample.png   86,65K   9 downloads

You must have the following running on your Raspberry Pi:
- Apache web server
- PHP5
- MySQL Server
- phpMyAdmin is very handy

Above installation you can find here.:
-How To Install Apache And Php On Your Raspberry Pi
-How To Install Mysql

The files you need are in this file compressed so if you decompress it , use for example WinSCP to send the files to your Raspberry Pi.
Bijlage  webcontrol.rar   28K   5 downloads
Bijlage  phpmyadmin7.png   44,07K   11 downloads

So first we upload the gpio.sql into phpmyadmin so we have the table installed for using it.
Bijlage  phpmyadmin.png   250,38K   6 downloads

Now, you need to add a user to the database from within phpMyAdmin. To do this;
Click the "Users" button on the top bar.
Now click the "Add User" link (about half way down the page on the left).
In the "User name" field, enter a suitable username. I went with "gpio".
In the "Host" field, enter "localhost".
Then in the two password fields, enter a suitable password. (No spaces, Hypehens or special characters). I went with "vbib123".
Now leave all of the rest as default, then click the "Add User" button on the bottom right.
Bijlage  phpmyadmin1.png   173,28K   4 downloads

The final part for this step is to give the user the correct privileges.
Click the "Users" button on the top bar, then scroll down until you see the user you have just added in the "Users Overview" table.
Across from the username, click the "Edit Privileges" link.
Scroll down to the heading "Database-specific privileges" and select "gpio" from the drop down list box, and click the "Go" button.
Select ALL of the check boxes, then click the "Go" button on the bottom left.
Bijlage  phpmyadmin2.png   45,86K   2 downloads

Congratulations - That's the database set up.

Shell Script

This is the part that runs on your Raspberry Pi checking for the values in the MySQL Database.
This script is pretty simple, but does require setting up.

You must change the following variables at the top of the file:
mysqlusername="USERNAME HERE"
mysqlpassword="PASSWORD HERE"

These must be changed to the username and password you created previously in phpMyAdmin.
Bijlage  phpmyadmin3.png   163,7K   3 downloads
That's it for the shell scripting session.

Web Page Setup

Okay - the final step before you can use this is to set up the webpage.
You must edit a few variables in the file control.php before use:

Change the following variables:

Now, navigate in your web browser to the control.php page. (mine is http://xx.xxx.xxx.xxx/control.php) where raspberryPi is your host name.

It will ask you to login with the following credentials:
Username: admin
Password: gpio

I recommend clicking the "Change Password" link at the top of the page, and changing the password for obvious reasons.

That's the end of the Web Page section.


To start the GPIO programs, do the following:

Start an SSH session with your Raspberry Pi, and login as root, then type in:
./GPIOServer.sh and hit Return / Enter.
Bijlage  phpmyadmin4.png   9,63K   1 downloads

It will ask you to input a wait time, this will depend upon your application needs, but the shorter the wait time, the more resources the script will use. (I generally use 5).
Bijlage  phpmyadmin5.png   15,91K   0 downloads

The the script is going to run and in mean while checking the sql db.
Bijlage  phpmyadmin6.png   16,83K   0 downloads

Now login to the web control interface, (http://HOSTNAME/control.php), login and enjoy.

Veranderd door pascalbianca, 08 december 2012 - 12:30.

Ook met taq PI, Web Control, GPIO voorzien

0 gebruiker(s) lezen dit onderwerp

0 lid(leden), 0 bezoeker(s), 0 anonieme gebruikers


[PI] Untitled 1

Met dank aan J├╝rgen voor de jarenlange inzet van visualbasic.be (anno dec 2000)
Met dank aan Mike en Ronneke voor de jarenlange inzet van vbib.be (anno dec 2010)
Met dank aan PascalBianca voor de jarenlange inzet van vbib.be (anno dec 2016)