Control GPIO modules connected to a Raspberry Pi via PHP
This a very simple PHP scritp I wrote to control my bedside lamp with a relay module connected to a Raspberry Pi and my cell phone. It is very straight forward and simple to use.
sudo apt-get install lighttpd php
Yup, that simple. Once lighttpd (or apache2 if you prefer) and php are installed place the script in the /var/www/html folder. It is important that the correct GPIO pins are mapped so the script can work properly.
You can access the script on the http://RASPBERRY_IP/ where RASPBERRY_IP is the ip adress of your Raspberry Pi.
Ideally your Raspberry Pi is connected to the Internet so bootstrap css script is loaded from the Internet.
A Arduino/Raspberry compatible module is required for the script to work. These modules are quite cheap and available on eBay or Amazon.
- Raspberry Pi 2/3/4/Zero
- 4 channel Arduino/Raspberry Pi compatible module.
GPIO and Relay module connections
In order to the script work with the GPIO mapped properly make sure that the pins are connected as follows:
|GPIO PIN||Relay module PIN|