Simple-PHP-GPIO

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.

Requirements

Software

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.

Hardware

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.
4 channel relay

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 PINRelay module PIN
2VCC
6GND
12IN1
13IN2
15IN3
16IN4

Github reposirtory

https://github.com/adelorenzo/Simple-PHP-GPIO

Leave a Reply

Your email address will not be published. Required fields are marked *