3

I have a Pi set up with Apache and wiringpi, and I would like to read the state of an in pin (every 20 seconds, if possible) and display it on my webpage using PHP. The input is to determine if my computer is on or off remotely.

So basically, I want to store the output of a system(gpio -g read 7) command into a variable ($status) and then print it on the page like so:

Your computer is currently: $status.

Where $status can be either on or off depending on if the read command comes back as a 1 or 0.

I can post what code I already have, but right now it just sends a power toggle out of a GPIO out pin.

Any help is appreciated! Thanks.

0x3C
  • 31
  • 2

1 Answers1

1

If one googles this phrase "raspberry pi gpio web interface" and switches to images mode, we can see that there appear to be quite a number of pre-existing solutions and samples. For example:

http://hackaday.com/2013/02/02/easy-web-interface-with-gpio-access-runs-on-raspberry-pi/

https://www.raspberrypi.org/forums/viewtopic.php?t=15257

http://www.cupidcontrols.com/2014/04/raspberry-pi-cupid-webio-javascriptjquery-apache-python/

and quite a few others.

Kolban
  • 1,794
  • 2
  • 16
  • 28