PiRelay Installation

Install The Software On Raspberry Pi

There are 2 methods of installing the software to use Pi Relay. 

Method 1. which is simple, and for people who either need it up and running quickly, and/or don’t have experience running Linux commands manually.

Or

Method 2. which is the manual install for people who prefer to know/learn how to configure the software, or to customise the installation.

Method 1.

Restore a Pre-installed image to your SD Card (Quick & Easy)

1.1.  Download Pi Relay app from the Play Store here: PiRelay App Download

1.2.  Download one of the Pi Relay SD Card Images here:

You simply need to download your chosen version of the zip files below and extract the image, then restore it to your SD card.

or

Once downloaded and extracted use an SD Card Image Writer such as: http://sourceforge.net/projects/win32diskimager/files/latest/download to write the extracted image to your SD card.

Finally just put the SD card into your Raspberry Pi and power it up.

That’s it… your Pi is now ready to use with PiRelay App to start switching or pulsing stats of your GPIO pins.

If you’ve successfully used this method, then you can now skip to the Hardware Configuration section of this guide.

NOTE: Method 1. will erase all existing data from the SD card.

Method 2.

Manual Software Install / Configuration

Setting Up Your Android Device

2.1.  Download Pi Relay app from the Play Store here: PiRelay App Download

In the app settings you can define a custom Server URL. This is the network path to your Raspberry Pi. The default path is “http://raspberrypi/”, however you can define an IP address or a custom URL. If you want to use PiRelay using Mobile Data then you will need to configure your own port forwarding on your router (By default PiRelay uses Apache2 on port 80).

Setting Up Your Raspberry Pi

2.2. Run terminal commands to install PiRelay on your Raspberry Pi

To install the required software on the Raspberry Pi you need to run the following commands at the Linux command line interface. To make it quicker and easier I use Putty on windows to SSH straight onto the Pi, but that’s not required, you could just type in these commands directly into the command line on the Raspberry Pi.

You should be able to run these commands with any Debian based Linux distribution, however I would recommend using the latest version of Raspbian (At the time of writing this the latest version is Jessie) from http://www.raspberrypi.org/downloads.

NOTE: Your Raspberry Pi needs to be connected to your network either via WiFi or an Ethernet Cable for Pi Relay to be able to access the RaspberryPi.

Commands to Install: Wiring Pi

git clone git://git.drogon.net/wiringPi

cd wiringPi

git pull origin

./build

 

Commands to Install: Apache & PHP

sudo apt-get install apache2 -y

sudo apt-get install php7.0 libapache2-mod-php7.0 -y

Create the PHP Script

Use the following command to launch the Nano File Editor and generate the gpio.php file:

sudo nano /var/www/html/gpio.php

Then copy the following into the Nano Editor:

<!DOCTYPE html>
 <html>
 <body>
 <?php
 $output = shell_exec('gpio mode '.$_GET['pin'].' out');
 $output = shell_exec('gpio write '.$_GET['pin'].' '.$_GET['status']);

for ($i = 0; $i < 32; $i++){
 $output = shell_exec("gpio read ".$i);
 echo "Relay ".$i.":".$output."<br>";
 }
 ?>
 </body>
 </html>

To exit the Nano Editor press Ctrl+X together. When it asks if you want to save the file press “Y” for “Yes” and press Enter! to save your gpio.php file.

That’s it… your Pi is now ready to use with PiRelay App to start switching or pulsing stats of your GPIO pins.