Raspberry pi remote light switch (by phone)



Following is project making remote light switch which can be controlled from (normal) Local switch or from Phone. It will help you to turn on or off light without touching Local switch on wall.
Just using a phone! Some cases like reading book on bed, no need to stand-up to turn off light, then go back to bed. By this project, you can use your phone to turn off light, then go sleeeep.

Here is result (demo):




Here is result (complete): PCB toggle switch + Phone application





1. Toggle circuit
This circuit is designed to detect pulse from "normal switch" or from "remote switch" (by phone)
This circuit will help User can turn on/off in by "normal switch" or by "remote switch". So, in case can't using "remote switch", User still can turn on/off light by "normal switch"

IC-555 is center of circuit for toggle switch.


As in Schematic, there are two section:
   (A). Toggle circuit by IC-555
   (B). Trigger signal:
        (1). Capacitor and opto are used to detect rising/ falling edge from "normal switch"
        (2).  "Remote switch" (by phone)

Following is completed PCB board


2. Remote switch
Raspberry Pi will be used for "remote switch"
Raspberry Pi will host a local web (which contain "remote switch"), and also connect to Wifi. So, User will use phone (connected to Wifi), open local web to turn on/off light.

2.1. Hardware
Raspberry GPIO map

Pin 7 (GPIO7) will be used for "remote switch". So, Pin 7 and Pin 6 (GND) will connect to Schematic toggle switch (in Section 1)

2.2. Making local web interface:
2.2.1. Install WiringPI
WiringPI is used to control GPIO
$ 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
$ ./build

Checking 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

2.2. Install web server:
Install Apache HTTP server and PHP5 extension
$ sudo apt-get install apache2 php5 libapache2-mod-php5

2.3. Web interface to GPIO of Raspberry
Local web uses php to control GPIO through WiringPI (installed in Section 2.2.1)
To interface between local web and Rasberry, there is tutorial in Instructable, this web project is mainly base on that tutorial, link here.

After modify again, making local web as following

Local web is save in /var/www/
(note that: The file "temp" should be changemod to 777)

Total my local web can be download at link here (Google share)


2.3. Control by Android app
Fortunately we successful made an Android App, it's easy for User to turn on/off light
The App can be download from Google store with keyword "Data2server" or this link

The screen of App looks like this:

There are 2 settings for local web address, and key setting:

First of all, user need to check connection status from Phone to Raspberry board. That's it! The light switch is in your Phone!






You might also like:
1. Raspberry pi - remote control car camera
This project will make remote car control which can view camera attached on car.
It will need:
Hardware side:
1. Car toy
2. Two gear motor
3. Raspberry B+
4. Wifi dongle
5. Power bank (10A) (for Raspberry board)
6. Battery (for gear motor)
7. H-bridge circuit (L298N)




2. Rasbperry pi - FFmpeg install and stream to web
Following tutorial will show how to install FFmpeg into Raspberry Pi, then stream video to Local web which can be access through Computer/Phone/Tablet








28 comments:

  1. When you turn on/off by real switch, is it possible to update automatically gpio pin status on phone also?

    ReplyDelete
    Replies
    1. Hi, basically we can update GPIO pin status. In order to reduce cables from Raspberry to Toggle circuit, so i don't make pin-status function.

      If you are interested in this, you can do:
      In file "index.php", we output pin by command: gpio mode 7 out
      So, to read pin no.6:
      (1) Config pin6 as input: gpio mode 6 in
      (2) Read pin6: gpio read 6
      (3) Raspberry will feed back pin 6 status

      Hope can help you.

      Delete
  2. can i control this from anywhere in the world?

    ReplyDelete
    Replies
    1. Sure, just open port for Local Web. But i dont like to control through Internet because we only need to control light right near us. Far away light is no-meaning to us

      Delete
  3. Replies
    1. This is RPi2, but this project can work with RPi3 also.

      Delete
  4. where you done the simulation of toggle circuit.its in multisim? and can i find library of octocoupler acpl-214-500e on proteus or not?

    ReplyDelete
    Replies
    1. Yes, i tried in Multisim. For opto-coupler, you can find replaced one.

      Delete
    2. please tell me its replacement

      Delete
  5. and can you send me its pcb layout

    ReplyDelete
    Replies
    1. I used Eagle to make PCB Layout, you can download it here
      https://drive.google.com/file/d/0B1UeJfx4pZ1GS21DSWJYZWZSRms/view?usp=sharing

      Frankly talking, make PCB will take a lot of time. Instead, i suggest to use another Arduino board act as Toggle circuit. As my experience, PCB should make some adjustment for resistor of transistor, sometimes it influence by noise.

      Delete
  6. Thanks a lots for suggesting Arduino I think I can make multiple Toggle switches with Arduino

    ReplyDelete
    Replies
    1. with Arduino, you can control many Light switch, also reading Light status (ON or OFF), or even reading power consumption with current sensor. However, to communicate from Rasp to Arduino, i think we should use RF board. I will make another article about this: a solution for Home appliance by IoT

      Delete
    2. Ok sir please make it soon and also include Light status (ON or OFF), and Power Consumption.

      Delete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Wow its a very good post. The information provided by you is really very good and helpful for me. Keep sharing good information.I bookmark your blog because I found very good information on your blog

    ดูหนังออนไลน์

    ReplyDelete

  10. Good tips. I will be sharing this with all of my friends! I like this post because it is informative and helpful to all readers. I would like to revisit this post. If you planning buy the Wholesale Cell Accessories or Wholesale iPhone 6 Plus Accessories and other all type mobile phones accessories. WholeCellUSA is the Best platform to get Whole Cell Phones and Accessories. Screen protectors are one of the most important accessories in the world of smartphones.

    ReplyDelete
  11. Searching Nodered, it is way easier to control GPIO and many thing from RP

    ReplyDelete
  12. A very nice article written. With joy I read your blog.

    ReplyDelete
  13. Excellent blog, good to see someone is posting quality information. Thanks for sharing this useful information. Keep up the good work.
    Wireless Light Touch Switch

    ReplyDelete
  14. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. also found some interesting topic on Roblox

    ReplyDelete
  15. It contains wonderful and helpful posts. Keep up the good work !. Thank you for this wonderful Article! I also have something for you. you can Check here

    ReplyDelete