srisawats
Posts: 1
Joined: Thu Apr 21, 2016 1:57 am

Re: Control Relay Switches via Android using a Raspberry Pi

Mon Apr 25, 2016 3:15 am

Hi jazzler,
First , thank you for sharing this program and sorry for my bad english.
Your program worked fine on my raspberry pi 3 which android app.
But at the moment my raspberry pi 3 used 3.5 inch lcd , so some GPIO pin could not used by your program.
LCD pin: 11 , 18 , 19 , 21 , 22 , 23 , 24 , 26
Relay control pin: 7 , 11 , 12 , 13 , 15 , 16 , 18 , 22
How can I change to other GPIO pin ?

deabrua
Posts: 1
Joined: Sat Apr 30, 2016 2:03 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Sat Apr 30, 2016 2:11 pm

Hi there,
I´ve just purchased PiRelay program on Google Play. Everything work fine even if you are out of your LAN by typing http://MyWanIp:PORT.
But it´s insecure because anyone who has PiRelay installed an knows my public IP (no-ip, dyndns...) can activate my relays. Is there anyway to make it more secure? May be adding some more code lines on PHP script....

Thank you very much for such fantastic program

jepe63
Posts: 9
Joined: Wed May 04, 2016 11:15 am

Re: Control Relay Switches via Android using a Raspberry Pi

Sun May 08, 2016 8:45 am

Hi Jason , where can i change the pins used ? , I've ordered a touchscreen for my Pi B and i am wondering if the pin layout is going to interfere with the relais used.

Also is there a possibility for the android app to build rotate in it ? i've been using it for years now on my tablet and getting tired of rotating the tablet :D

tom.slick
Posts: 190
Joined: Wed Jan 06, 2016 9:23 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Fri May 13, 2016 5:04 pm

jepe63 wrote:Hi Jason , where can i change the pins used ? , I've ordered a touchscreen for my Pi B and i am wondering if the pin layout is going to interfere with the relais used.

Also is there a possibility for the android app to build rotate in it ? i've been using it for years now on my tablet and getting tired of rotating the tablet :D
Use this in place of gpio.php
Change $gpio_pins to the wiringpi pins you want to use
Use this image to get the correct pin number
http://pi4j.com/images/p1header.png

/www/var/html/gpio.php

Code: Select all

<!DOCTYPE html>
<html>
<body>
<?php
// change the values in $gpio_pins to the pins you need
// Note: changing the order of the pin in the array will change the button that affects that relay.
$gpio_pins = array(0, 1, 2, 3, 4, 5, 6, 7); 
$value = intval($_GET['pin']);

if ($value >= 0 and $value < 8) {
    switch ($value) {
        case 0:
            $pin = $gpio_pins[0];
            break;
        case 1:
            $pin = $gpio_pins[1];
            break;
        case 2:
            $pin = $gpio_pins[2];
            break;
        case 3:
            $pin = $gpio_pins[3];
            break;
        case 4:
            $pin = $gpio_pins[4];
            break;
        case 5:
            $pin = $gpio_pins[5];
            break;
        case 6:
            $pin = $gpio_pins[6];
            break;
        case 7:
            $pin = $gpio_pins[7];
            break;
    }
    $output = shell_exec("gpio mode '$pin'  out");
    $output = shell_exec("gpio write '$pin' " .$_GET['status']);
}

echo $_GET['status']; // didn't know why this was done so I left it in

for ($i = 0; $i < 8; $i++){
    $ii = $i + 1;
    $output = shell_exec("gpio read '$gpio_pins[$i]'");
    echo "Relay ".$ii.":".$output."<br>";
}
?>
</body>
</html>

jepe63
Posts: 9
Joined: Wed May 04, 2016 11:15 am

Re: Control Relay Switches via Android using a Raspberry Pi

Sun May 15, 2016 8:20 am

Thanx , that's working fine, alltough it's var/www/html/gpio.php but that's a detail ;)

tom.slick
Posts: 190
Joined: Wed Jan 06, 2016 9:23 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Sun May 15, 2016 8:24 am

jepe63 wrote:Thanx , that's working fine, alltough it's var/www/html/gpio.php but that's a detail ;)
Most of the time the error is with copy and past, this time it's because I didn't copy and past :lol:

cr3x
Posts: 7
Joined: Mon Jul 11, 2016 2:31 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Mon Jul 11, 2016 2:36 pm

Hi guys, it tooked me a long time to figure it out, but finally i did it!

To all of you who has "Unable to check relay status" just put "/' behind your IP in app. e.g. http://192.168.2.9/

At least in my case that was a problem.

cheers to all and have a fun with your Relay projects!

Jan9292
Posts: 1
Joined: Wed Jul 13, 2016 5:59 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Wed Jul 13, 2016 6:08 pm

The next feature I want to implement is the ability to define a 'Delay Off' value to a relay, e.g. If delay off on Relay 1 was set to 2 seconds, then 2 seconds after turning it on, it will turn off the relay. This is useful for applications such as Garage Door openers which require a short signal to Open/Close the Garage door etc.
[/quote]

If this option is already available?

arniesaccnuson
Posts: 2
Joined: Wed May 04, 2016 9:17 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Sat Oct 08, 2016 12:12 am

Hi,
Thank you for this app, I have the pro versions and it works very well and was very easy to setup. I have read through the 5 pages of posts and I have a question that has been asked a few times before but as there has been no reply I thought I would ask it again:
I have two Pi's on the same network, is there any possibility that the App will one day be able to control TWO servers?. I have looked around and what is available elsewhere and it is pretty horrible, I am personally happy to pay again for a "pro plus app"

yrral64
Posts: 1
Joined: Mon Oct 10, 2016 1:21 am

Re: Control Relay Switches via Android using a Raspberry Pi

Mon Oct 10, 2016 1:28 am

Doesn't detect my relays what should I do

Letakeh
Posts: 2
Joined: Tue Oct 11, 2016 12:59 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Tue Oct 11, 2016 2:35 pm

Hi
I bought the PiRelay Pro on google play and created the flash card with the latest image (2015-09-24-raspbian-jessie-pirelay.zip). My PI2 is working ok on HDMI screen. It's IP (from DHCP) is 192.168.1.220 and when this IP is used as address on browser I can get one Apache page. Looks all ok but I can't get the GPIO's Status confirmation on App, neither the working level at any GPIOs pins.
Is it necessary to add some GPIO access from network? If yes, how?
Thanks.

Letakeh
Posts: 2
Joined: Tue Oct 11, 2016 12:59 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Wed Oct 12, 2016 10:26 pm

Cr3x aswered my question already.
Just include one "/" after the IP

Thanks a lot Cr3x

Watchitexplode
Posts: 2
Joined: Sat Oct 15, 2016 11:32 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Sun Oct 16, 2016 12:30 pm

Letakeh wrote:Hi
I bought the PiRelay Pro on google play and created the flash card with the latest image (2015-09-24-raspbian-jessie-pirelay.zip). My PI2 is working ok on HDMI screen. It's IP (from DHCP) is 192.168.1.220 and when this IP is used as address on browser I can get one Apache page. Looks all ok but I can't get the GPIO's Status confirmation on App, neither the working level at any GPIOs pins.
Is it necessary to add some GPIO access from network? If yes, how?
Thanks.
I am having a similar problem, but adding the "/" didn't help.

I get the Apache page when entering the Pi's IP, but when I enter myip/gpio.php I get a 404 not found, "The requested URL /gpio.php was not found on this server."

I'm using a Pi 3 and did Method #2 on a fresh install of Raspbian Jessie with Pixel. I tested the relay from the terminal and it works.

Did I miss a step somewhere in the setup? Thanks! :D

EDIT: In my /var/www/html directory I have the files "gpio.php.save" and "index.html" Do I need to do something with those?

jazzler
Posts: 31
Joined: Mon Nov 04, 2013 7:43 am

Re: Control Relay Switches via Android using a Raspberry Pi

Wed Oct 26, 2016 6:38 pm

Hi All

Sorry I've been quiet for so long, lots of changes in my life over the past couple of years meant that I haven't had time to work on developing this for a while. I wont have time to answer everyone's questions but will try to drop in from time to time help where I can.

At this point in time I don't have an android phone to test and develop on. I'm working on that and saving to get an android phone soon, at which time I plan to pick up the development of this again to improve it.

Great to see so many people using the app, and initially there are a few things I want to address:

Security - Those who want to make their Pi accessible from outside their network and are concerned about security, my advise is to setup a VPN (Perhaps setup open vpn on your Pi) and use that instead of making Apache on your Pi externally accessible. That's what I do when i need to access my Pi and it works great.

Multi Pi Support - I intend to start developing the app again once I get myself an android phone, when I do I plan to add support for controlling multiple Pi's.

Development Timescales - Please bare with me, I cannot commit to any development timescales for new features as it will rely on 1, me getting an android phone and 2, me having free time to spend after work, in evenings and weekends to develop and test new functionality. Please do not message me asking when new functionality will be added or when to expect updates.

App Testers - If anyone is interested in being a tester and running a dev build of the app to help me test and iron out any bugs that come out of the new functionality, please PM me. There will inevitably be bugs in the dev version that need finding and fixing, so please do not request to become a tester if you cannot deal with this. You have been warned...

Support for more than 8 relays - I originally limited this to 8 relays for 2 reasons, 1 - a typical relay board available at the time of developing it had 8 relays or less. 2 - I was aware that like me many people would be powering their relay board directly from the Pi and I was concerned that if I developed the app to allow people to use more than 8 relays, the power drain from the relay board on the Pi might cause issues or damage which I did not want to be blamed for. That said, there appears to be a great demand for this so I plan to include support for any/all available GPIO pins. I ask that those who intend to use this feature please consider powering your relay board directly from its own power source and not from the Pi iteself. I do not accept any responsibility for any damage or harm you cause using PiRelay, so please use it responsibly and manage your power requirements yourself.

Today I have created a new SD Card Image, based on the latest Raspian Jessie Lite. I have built it on a 2GB SD card and made it available to download from here: http://bit.ly/raspbian-jessie-lite-pirelay. This much smaller package should allow you to make use of PiRelay using smaller capacity SD Cards from 2GB upwards, although I recommend using 4GB or larger (Is it just me or do we all have lots of old low capacity SD cards laying around that would be handy to revive and put to good use?)

Anyway, that's all for now, thanks for your support so far and a big thanks to those of you that have been helping out others by replying to peoples questions in this thread.

P.S.
Watchitexplode - You need to name the php file gpio.php and not gpio.php.save it should work for you then assuming you have added the contents to the file correctly and installed the required components.
Last edited by jazzler on Tue Mar 07, 2017 8:50 am, edited 2 times in total.
PiRelay Project : http://bit.ly/pirelay
PiRelay Play Store App : http://bit.ly/PiRelayApp

tween
Posts: 1
Joined: Tue Nov 08, 2016 9:37 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Tue Nov 08, 2016 9:43 pm

Hi guys!
The post is awesome fo my project!
But how can I control two pins at a time by one HTTP request like http://192.168.0.100/gpio.php?pin=7&status=1

Need to tun ON\OFF PIN7 and PIN0 by one request.
Thank you very much for the answer!

Watchitexplode
Posts: 2
Joined: Sat Oct 15, 2016 11:32 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Thu Dec 08, 2016 4:47 pm

jazzler wrote: P.S.
Watchitexplode - You need to name the php file gpio.php and not gpio.php.save it should work for you then assuming you have added the contents to the file correctly and installed the required components.
Thank you for the response! I thought that might be the problem, but couldn't figure out how to rename the file! :oops: (I'm a Pi and Linux newb). I'll edit this post after I give it a try.

jazzler
Posts: 31
Joined: Mon Nov 04, 2013 7:43 am

Re: Control Relay Switches via Android using a Raspberry Pi

Thu Dec 08, 2016 4:53 pm

Watchitexplode wrote:
jazzler wrote: P.S.
Watchitexplode - You need to name the php file gpio.php and not gpio.php.save it should work for you then assuming you have added the contents to the file correctly and installed the required components.
Thank you for the response! I thought that might be the problem, but couldn't figure out how to rename the file! :oops: (I'm a Pi and Linux newb). I'll edit this post after I give it a try.

No problem, try running this at the command line:

Code: Select all

mv /var/www/html/gpio.php.save  /var/www/html/gpio.php
PiRelay Project : http://bit.ly/pirelay
PiRelay Play Store App : http://bit.ly/PiRelayApp

M-XXXX
Posts: 1
Joined: Thu Jan 26, 2017 10:48 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Thu Jan 26, 2017 10:57 pm

Hello, I have purchased your Pro application. So far I got it working on PC browser on the same network, but not from my phone (from the IP).

Should be there some more instruction on your webpage? https://sites.google.com/a/jasonfindlay.com/pi-relay/ To me it looks like its just end with pictures and I assume there should be some more text?

How can I connect to it raspberry from my phone from internet (not within the same network)?
Comments say with IP+gate, same say to use / at the end, but nothing works. Any more ideas or links to figure it out?

PS: I'm new programming and raspberry, but I'm learning and exploring this wonderful mini PC :)

paulmorris30
Posts: 1
Joined: Sat Jan 28, 2017 11:26 pm

Re: Control Relay Switches via Android using a Raspberry Pi

Sat Jan 28, 2017 11:29 pm

Hi, I just updated the android app and its gone back to a trial, now a need to pay AGAIN to keep it working!

jazzler
Posts: 31
Joined: Mon Nov 04, 2013 7:43 am

Re: Control Relay Switches via Android using a Raspberry Pi

Sun Jan 29, 2017 6:30 am

Hi PaulMorris30,

You don't need to pay again, I have issued a Play Store update which will sort it out for you. Please update the app again and your licence should now show as purchased . Also PM sent..
PiRelay Project : http://bit.ly/pirelay
PiRelay Play Store App : http://bit.ly/PiRelayApp

poweredbyant
Posts: 10
Joined: Mon Dec 10, 2012 2:17 am

Re: Control Relay Switches via Android using a Raspberry Pi

Sun Jan 29, 2017 4:57 pm

About time today update pirelay and got what i need after wait for years well done jason! Keep up the good work will let know if any bugs / feedback

jazzler
Posts: 31
Joined: Mon Nov 04, 2013 7:43 am

Re: Control Relay Switches via Android using a Raspberry Pi

Sun Jan 29, 2017 7:09 pm

poweredbyant wrote:About time today update pirelay and got what i need after wait for years well done jason! Keep up the good work will let know if any bugs / feedback
Hi there poweredbyant... Very pleased to see you are still here, still using the app and are pleased to receive the update. :D

Yes I got myself an Android phone again in December and got to work on an full overhaul update which I released last night.

Eagle eyed fans will have noticed that I uploaded a new PiRelay Jessie SD card image for PiRelay2.0 a couple of weeks ago on my website (http://bit.ly/pirelay) in preparation for this update.

If you haven't done so already, you may want to consider either updating your gpio.php to the new one referenced on my website, or alternatively update your SD card image to the new one as the new version supports refreshing the status of WiringPi pins 0 to 31. The update will still work with the old gpio.php for switching but it would only be able to refresh WiringPi pins 0 to 7 (unless you have already customised yours?).

Play Store Link: PiRelay

Features in PiRelay v2.0
- Control up to 100 Relays
- Use up to 5 Raspberry Pi's
- Ability to send a pulse signal (i.e. Switch relay on then immediately off)
- Swipe down to refresh relay status
- Ability to assign Icons to relays
- Alternative On/Off Icons
- Refresh relay status
- Screen rotation
- Pi Header Diagrams for Rev1 (P1) & Rev2 (J8) boards
- Ability to change the Title Bar Name
- Ability to set the Wiring Pi Pin # used by each relay
- Ad Supported Free App with optional "In App Purchase" to remove ads

Have fun playing....

P.S. I've also got PiRelay working with my Amazon Echo by using the IFTTT Maker Channel.. When I get time I plan to write some instructions on how to set that up too.
Last edited by jazzler on Sat Feb 11, 2017 10:14 am, edited 9 times in total.
PiRelay Project : http://bit.ly/pirelay
PiRelay Play Store App : http://bit.ly/PiRelayApp

jazzler
Posts: 31
Joined: Mon Nov 04, 2013 7:43 am

Re: Control Relay Switches via Android using a Raspberry Pi

Sun Jan 29, 2017 7:45 pm

M-XXXX wrote:Hello, I have purchased your Pro application. So far I got it working on PC browser on the same network, but not from my phone (from the IP).

Should be there some more instruction on your webpage? https://sites.google.com/a/jasonfindlay.com/pi-relay/ To me it looks like its just end with pictures and I assume there should be some more text?

How can I connect to it raspberry from my phone from internet (not within the same network)?
Comments say with IP+gate, same say to use / at the end, but nothing works. Any more ideas or links to figure it out?

PS: I'm new programming and raspberry, but I'm learning and exploring this wonderful mini PC :)
Hi there.. Thanks for purchasing and supporting the app and it's continued development.

In the new app you shouldn't need to add a / to the end of the server name etc on the new version of the app. You simply need the http:// followed by the hostname of your Pi or the IP Address (e.g. http://raspberrypi). By default it operates on the LAN on Port 80 so you only need to specify a port at the end with a : (e.g. http://raspberrypi:8081 if you have changed Apache to use a custom port such as 8081 or whatever you choose, although you have not done this so just set it without a port number).

The default hostname of a Pi on Jessie is "raspberrypi" so if you haven't changed anything then for LAN access leave it as http://raspberrypi

For WAN access (i.e. over the internet) you have at least 2 options I can think of:

Option 1 (hard but most secure). Set up a secure VPN and connect your phone to it whenever you want to control the Pi.

Option 2 (easier but less secure). Use Port Forwarding.

I'm not going to go into detail on how to setup option 1 however to use option 2 you will need to setup port forwarding on your router. Since there are 1000's of different routers out there I can't provide instructions on how to setup every one, but you could check this website and find your router for guidance: https://portforward.com/router.htm.

My recommendation if you are going to use port forwarding would be to pick a random port that's not already in use on your network (e.g. 49152), then setup your router to translate incoming connections on your chosen port number to port 80 on your LAN and to forward them to your Pi's local IP address on your LAN. Then in PiRelay App, set the url to your external IP with your chosen port number. for example if your external IP is: 10.20.30.40 and you are using the port in the example above then you would set the Pi URL in the app to: http://10.20.30.40:49152

I do not recommend forwarding port 80 from your external IP to port 80 on your LAN. Instead use a custom port externally and get the router to translate it to port 80 on your LAN which will make it a bit more secure.

The reason my instructions on the website end where they do is because you are now entering the realms of networking and since everyone has their networks setup differently I can't possibly give detailed instructions on all the different ways to configure everyone's networks.

I hope this info helps you out. Good luck with your project...
PiRelay Project : http://bit.ly/pirelay
PiRelay Play Store App : http://bit.ly/PiRelayApp

poweredbyant
Posts: 10
Joined: Mon Dec 10, 2012 2:17 am

Re: Control Relay Switches via Android using a Raspberry Pi

Sat Feb 04, 2017 9:12 pm

hi again ... the early days on this forum.. as shows example how change status 0,1 from webpage e.g ..

The app sends a http get request e.g. to make GPIO 1 active: http://YOUR-PI-IP-ADDRESS/gpio.php?pin=1&status=1

And to make it inactive: http://YOURPI-IP-ADDRESS/gpio.php?pin=1&status=0

Try this in your web browser, chaing the Pin number / Status Number (1 on 0 off).

but i just forget how to do pulse relay like sent once it turn on then off like an push button?
as trying do an url sent from esp8266 to pirelay in the raspberry pi ;-)
thanks cheers Ant.

hassesthlm
Posts: 3
Joined: Wed Oct 23, 2013 9:35 am

Re: Control Relay Switches via Android using a Raspberry Pi

Sun Feb 05, 2017 2:41 pm

Hey all,
need help to get my relay work
can use the app to turn on the relay, but not deactivate
do not understand why or relay defective
:oops: :roll:

Return to “Automation, sensing and robotics”