Raspberry Pi GPIO From Phone

5,141

72

11

Introduction: Raspberry Pi GPIO From Phone

About: just share what i have to make life funny see my page https://www.youtube.com/c/engineer2you

Control Raspberry GPIO from Phone application. Through this, you can make your own Remote light switch 220V or FAN, etc.

--------------------------------------------------------

Parts to purchase:

1. Raspberry Pi https://amzn.to/2VJIOBy
2. Bread board https://amzn.to/2OiPWDk

Step 1: Make Local Web Server

1.1. Install WiringPI

WiringPI is used to control GPIO. On Raspberry, open command to install WiringPI:

$ sudo apt-get install git-core

$ sudo apt-get update

$ sudo apt-get upgrade

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

$ cd wiringPi

$ git pull origin

$ cd wiringPi

$ ./buildChecking after installation WiringPI

$ gpio mode 0 out

->If nothing special appears, everything's fine.

Sample command, write and read pin 1

$ gpio write 1 0

$ gpio read 1

1.2. Install web server:

To install web server, type command
$ sudo apt-get install apache2 php5 libapache2-mod-php5

If everything OK, a local web will display when you type address to Web Browser 192.168.1.71/index.html

1.3. Make PHP page to interface GPIO

Now we have WiringPI to control GPIO from command, we have web server. So, to use Web server control GPIO, we need make PHP page to control GPIO through WiringPI

In Raspberry:

$ cd /var/www/html

$ gedit io.php

Then paste the code as in this link

Note, this code i made for GPIO7, GPIO8, GPIO9

Step 2: Make Simple Circuit

Using bread board, some wires, resistor 220Ohm to connect GPIO7, 8, 9 to LEDs

Step 3: Control GPIO From Web Browser

Here we go, open Web browser, paste this address http://192.168.1.71/io.php?pin=70

Then, GPIO7 will off, to ON it, past address http://192.168.1.71/io.php?pin=71

Step 4: Control GPIO From Phone Apps (Android)

There is an Android App can be used to send php command. The App can be found in Google Play by keyword "Data2Server" or by this link

In this App, you will configure php address, command for GPIO ON and OFF. Also input IP address to Ping from Phone to Rasp for checking connection.

That's it! Now GPIO can be controlled from your Phone! By this, you can use it for control Light 220V or anything you like!

Be the First to Share

    Recommendations

    • Mason Jar Speed Challenge

      Mason Jar Speed Challenge
    • Bikes Challenge

      Bikes Challenge
    • Remix Contest

      Remix Contest

    11 Discussions

    1
    qaasimravat81
    qaasimravat81

    8 months ago

    Hi. I'm new to all this automation things but I would like to learn more about it.
    I have a raspberry pi 3 b+ with a 8 channel relay. I installed blynk and it works perfectly fine but the problem I'm having is that the on switch is off and the off switch is on a d when the pi reboots all things connected to the ralay goes on. Any advice on how to solve this??

    0
    AnnaMai
    AnnaMai

    Reply 8 months ago

    I dont know much about Blynk. Is it can be programmed like C++? If so, you make variable to remember state of relay, ofcourse the variable should save in file to prevent lost value when power off

    0
    SINCERE MENSAH
    SINCERE MENSAH

    3 years ago

    please i want too the pi where thee pi serves as the admin and andriod sreves as the user

    0
    AnnaMai
    AnnaMai

    Reply 3 years ago

    i didn't get your mean. Here, Pi is sever (admin), android is user

    0
    SINCERE MENSAH
    SINCERE MENSAH

    Reply 3 years ago

    The thing is all about when you send information from de andriod the pi will recieve a notification for it to be displayed on to screen.

    0
    AnnaMai
    AnnaMai

    Reply 3 years ago

    Almost same with this project, but you need do more:

    (1) Local web server (in Pi) receive command from user (Android phone)

    (2) Web server show result (you should use local variable to save result status)

    Here is another example for light switch where switch status is shown on local web

    http://engineer2you.blogspot.com/2016/06/raspberry-pi-remote-light-switch.html

    0
    mrlazzy
    mrlazzy

    3 years ago

    in the 1.3 part
    did u mean
    $ edit index.html ??
    i cant eddit the file
    where should i copy and paste the code??

    0
    AnnaMai
    AnnaMai

    Reply 3 years ago

    Hi Mr. Lazzy,

    copy the code to file io.php

    Code is in this link (Google share) https://drive.google.com/drive/folders/0B1UeJfx4pZ1GU0hta0c4LUpnV1E

    0
    mrlazzy
    mrlazzy

    Reply 3 years ago

    oh ok i had some troubles with gedit so first i did
    $ sudo apt-get install gedit

    and then
    $ sudo gedit io.php

    i am beginer so it was verry dificult to find out why i was not able to edit the file...
    thanks everything is working now

    0
    AnnaMai
    AnnaMai

    Reply 3 years ago

    Glad to help you.

    0
    AnnaMai
    AnnaMai

    4 years ago

    Whole step also can be view at my blog

    http://engineer2you.blogspot.com/2016/09/raspberry-gpio-from-phone.html