Web page button controls GPIO relay
#3
(04-17-2020, 10:16 PM)evilbunny Wrote:
(04-17-2020, 06:51 PM)coolio Wrote: Hi evilbunny,

Thanks for the info.  I've researched the ajax XMLhttpRequest and have it working, well I have a web page that allows me to run a "hello Dave"  cgi script
on my pine64...I've written a cgi script that when run from the command line turns ON and OFF a relay momentarily...
When I try to run the cgi script through the XMLHttpRequest event handler, I end up with an INTERNAL ERROR page on my web browser...

From my searching on the web the problem is related to the GPIO pins needing to run as ROOT...
I've spent 2 days (and nights) on this and am now officially giving up trying to do this on the pine64.

FYI - I'm heading back to the Raspberry pi and will use the wiringpi module, then right PHP code to do the same...


Hi all,
I'm looking for some advice with regards to controlling a relay from a web page. 

I am familiar with using the RPi.GPIO to control the actual relay(s) on the pine64.

What I am confused about it how to have the web page button onClick event send the python code to the pine64.
Does html have an event or method "onClick" or is this only available using javascript?

Would I create a html (PHP) webpage  add a button, then have a cgi script run the python RPi.GPIO code?

I'm trying to come up with the right strategy of how to go about this so any assistance would be greatly appreciated.

Thanks in advance
Dave


I'm toying about with a arduino board with wifi and basically did something similar.

I use onclick events to trigger a XMLHttpRequest request so I don't need to refresh the whole page just to use a servo
  Reply


Messages In This Thread
Web page button controls GPIO relay - by coolio - 04-17-2020, 06:51 PM
RE: Web page button controls GPIO relay - by coolio - 04-19-2020, 07:50 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)