I have a RPi3 running on Ubuntu Mate 16.04, im planning to create a web app that has the capacity to control my raspberry pi. I have done some research and seen WebioPi but with my full effort in installing it, it always result to an error. Can PHP and Python work together to control my raspberry pi? I don't see much of tutorials, would be really a great help if you guys could give me some resources.. sorry i'm still new to RPi, python and php
-
What would probably be useful is if you documented the recipes you followed, the steps you performed and messages generated as a result of the tasks. In addition, try and describe your end goal to ensure that we are heading in the right direction to begin with.– KolbanCommented Jul 22, 2016 at 14:59
2 Answers
The easiest method I've used for controlling the Pi and its GPIO pins like this is the Python based web framework Flask. The learning curve is fairly low and it has reasonably human-readable documentation.
There's an entry level Flask GPIO tutorial at mattrichardson.com that I found useful when I was getting started. The section 'Connecting the Web to the Real World' has a connection diagram and some sample code for a basic button reading program. The code's a little long to repost in its entirety here, but in essence it sets up a route to a single HTML page which responds to button presses on the Pi.
-
excellent choice with Flask. I have worked with it before and it is quite easy to get around. On the other hand, Django and other frameworks are really difficult. Commented Sep 12, 2016 at 9:25
I know it's a little late, but I have written a fairly comprehensive library which integrates nicely with a WebSocket server. This allows you to make a non-polling browser app which can send/receive events in realtime.
It's a native PHP implementation, and includes GPIO, SPI, I2C and PWM for all current Pi Models.
calcinai/phpi-websocket is the demo which provides a basic scaffolding for what you'd need.