Update: See Andriod/Arduino for Beginners - Design Custom Andriod menus to switch Arduino outputs on and off. Absolutely No Programming Required for an alternative that does not require any programming at all.


Control your Lights and Power from your AndriodTM mobile using Arduino.

NO Android Programming required. No Soldering required.
Power wiring required.

See www.pfod.com.au for more Android controlled example projects

Note: this instructable has been updated to replace the discontinued relay shield with Relay shield V2.0 .

Safety Warning
This project will be wired into the 110V-240V main wiring to switch devices on and off from your Android mobile. 110V-240V Mains is lethal and after you have put this project together, the wiring to the mains power should only be done by a qualified electrician.

You can give each relay your own personal name by editing the Arduino code as shown below. No Android programming is required.

An electrician should mount the project in a suitable insulated box and wire the four relays across the switches of the lights and/or power points you want to control.

This project is in three parts.

i)The basic control of 4 switches, called switch 1, switch 2, switch 3 and switch 4. This is what you get from the Quick Start.

ii) Customizing the names of your switches to give them meaningful names.

iii) Making one of the switches a Garage Door opener and the other three the Outside Light, Garage Light and Hall Light (shown above) or what ever name your want.

No Android programming is required to make and any of these three versions. Simple changes to the Arduino code completely controls what options are presented on the user's mobile.
By adding a bluetooth module and a small amount of code to make your Arduino device a pfodDevice, you can control your Arduino project from your Android mobile, in this case the Arduino turns relays on or off and pulses a relay which is in parallel with the garage door manual push button to open and close it.

pfodDevice's are controlled by a pfodApp. Imagine HTML re-designed for micros with short simple messages each less than 255 bytes to describe the pages. The pfodApp is the micro-browser and the pfodDevice is the micro-server. When the pfodApp running on your Andriod mobile connects, via bluetooth, to your Arduino, the pfodApp sends the request {.} which asks for the pfodDevice's main menu. The pfodDevice return a short messsage (max 255 bytes) which the pfodApp renders to give the user choices that control the pfodDevice. When your user selects a button or menu item, the pfodApp sends the associated command back to your Arduino to execute that function. Commands are typically a single character enclosed by { }. Your Arduino code extracts the command character from this message, using the simple parser below, and executes the associated function.

That's all there is to it. No Android programming is required and the only additional programming you need in your Arduino is the small command parser. All the text and prompts displayed on the Android mobile are completely controlled by the code in the Arduino. The same Andriod pfodApp can control any Arduino or other micro-controller which has been coded as a pfodDevice. If you want to test out how the pfod micro-pages will look on pfodApp, then set up a bluetooth serial connection to your pc as described here and type the micro-pages into the terminal window and see how pfodApp displays them. This also lets you see what messages the pfodApp will return for various user inputs.

As well as navigation buttons and multiple levels of menus, which the parser below handles, the pfod Specification also supports user input such as numbers, text and multi and single selection lists. A slightly larger parser is required to parse user input, see Remote Controlled LCD Display.

The pfod Specification has been designed to keep the micro-controller code (the Arduino code) simple. The micro-controller does not and should not remember the user's navigation history, the Android pfodApp does all that. The micro-controller should simply execute the function associated with the command it is sent and return a result message (often just {} ). See the pfod Specification for all the details and examples.

The Step 1 is the Quick Start which will give you 4 Android controlled switches.

Step 1: Android Controlled Lights and Power - QuickStart

1) Android Controlled Lights and Power – Quick Start

This quick start will give you control of 4 switches from your Android mobile.

The switches are named Switch 1, Switch 2, Switch 3 and Switch 4 and correspond to the Relay board terminal blocks 1,2,3 and 4.

The Android pfodApp shows the current state of each switch, ON or OFF. (The next step in this tutorial shows you how to set your own names for the switches.)

Here is the parts list of what you need and where I purchased my parts, it also contains alternative US sources for parts I purchased in Australia.

Quick Start

1) Install the Arduino IDE from http://arduino.cc/en/Guide/HomePage
2) Open a new File and copy this code to the IDE window, plug in the Arduino Uno via the usb cable and program it. Then un-plug the USB cable.
3) Set the switches on the Bluetooth board. Set the 3V/5V switch to 5V and set the To Board/To FT232 switch to the To Board position.
4) Plug the three boards together Arduino, Bluetooth, Relay board. Make sure the pins all line up correctly..
5) Plug the USB Wall Charger into the Arduino board via the USB cable, so that it will power all three boards.
6) Download the pfodApp to your Android mobile.
7) Pair your mobile with the Bluetooth shield and setup a pfod connection called Lights and Power, as described here.
8) Start pfodApp and click the Switch 1 to 4 buttons to turn the relays on and off. Check between COM and NC terminals for terminals 1 to 4 with a multi-meter on Ohms.
9) Have an electrician install in a mains rated box and wire the relays to the lights/power points you want to control. If you want to customize the names of the switches proceed to the next step before installing.
10) Finished.

The next step will show you how to edit the Arduino code to give the switches your own names.

<p>Relay Shield V2 has been discontinued, user <a href="http://www.forward.com.au/pfod/HomeAutomation/OnOffAddRelay/index.html" rel="nofollow">Relay Shield V3</a> instead. Or use another relay board, see <a href="http://www.forward.com.au/pfod/HomeAutomation/OnOffAddRelay/index.html" rel="nofollow">How to Add Relays to Arduino</a></p><p>Also you can now replace the BT shield with a cheaper WiFi shield.<br>See <a href="http://www.forward.com.au/pfod/CheapWifiShield/index.html" rel="nofollow">Cheap/Simple Wifi Shield</a> and <a href="http://www.forward.com.au/pfod/CheapWifiShield/index.html" rel="nofollow">ESP8266-01 Wifi Shield</a></p>
<p>I used the cheapest parts I could find on DX and ebay. It was a bit of a Frankenstein's monster, with a knockoff Arduino Uno (funduino), cheap relay board and BT module that looks nothing like the picture. The whole project worked first try. Fantastic stuff, thanks so much to the author. I now have a sprinkler system that is controlled by my mobile phone.</p><p>One question, is it possible to code the switches so that they will switch for a set amount of time before turning off? I would like to turn the sprinklers on and then let them run for a pre-programmed amount of time before they switch themselves off. I was going to give it a try myself, but I'm no programmer and this is my first Arduino project.</p>
<p>Sure you can do that. Use the Garage door part of the code and make the pulse longer.</p><p>Change <br>long pulseLength = 750; // 0.75sec<br>to<br>unsigned long pulseLength = 3600000; // for a 1hr pulse<br>email at pfod.com.au via support if you need help with the code.</p>
<p>The code for the pulsing the garage door push button was broken between 5th Jan 2015 and 2nd Feb 2015. Fixed now.</p>
<p>I have problems getting contact between my computer and my android. My computer has a Windows 8 driver, and the instructions is on windows 7, does this matter? </p>
<p>I don't have windows 8 but check out this tutorial</p><p><a href="https://learn.sparkfun.com/tutorials/installing-arduino-ide/windows" rel="nofollow">https://learn.sparkfun.com/tutorials/installing-ar...</a></p><p>which mentions special steps to get the driver running.</p>
<p><em style="">Note: this instructable has been updated to replace the discontinued relay shield with <a href="http://www.seeedstudio.com/depot/Relay-shield-V20-p-1376.html" rel="nofollow">Relay shield V2.0</a> .</em></p>
<p>Added note about new instructable that generates all the Arduino code for you and note about replacement relay shield.</p>
<p>fixed missing link to 240V version</p>
<p>Nice one..... can you provide me with 16 channel relay board and a wifi shield instead bluetooth.....</p>
<p>Also the drive to the relay cards needs to be active high, to allow for the voltage difference between the FioV3 3.3V and the 5V relay card</p>
<p>I have not built a 16 channel version.</p><p>See FioV3 wifi (with 128bit security) for a wifi example and wifi setup</p><p>http://www.forward.com.au/pfod/ArduinoWiFi_simple_pfodDevice/index.html</p><p>You need to add 2 x 8 channel 5V boards and wire them to the</p><p>digital outputs. Search for &quot;8-Channel 5V Relay Module Shield for Arduino&quot; for example</p><p>choose an optical isolated one or at least one with a transistor driver.</p><p>For FioV3 you can use outputs, 2,3,4,5,6,7,8,9,10,11,15,16,17, A0, A1, A3</p><p>(note you can use the Analog inputs as digital outputs)</p><p>Some code changes are needed, basically cut and paste for extra outputs</p><p>and Serial becomes Serial1 for send and receive on FioV3</p><p>It would need a bit of electrical design. </p><p>The FioV3 outputs are 3.3V, so need to check if that is enough to drive the 5V relay inputs.</p><p>If not then you need to add some resistors the ones already on the relay boards.</p><p>Also Turning 12 relays on will probably exceed standard 500mA USB supply. You need a 1A 5V supply.</p><p>Drop me an email via www.pfod.com.au and we can discuss the details. </p>
You could start with &quot;eaton's guide to surge suppression&quot; and http://en.wikipedia.org/wiki/Surge_protector. <br> <br>Then look up the manufacture's web sites for application notes on how to apply the various suppression devices. <br> <br>Finally, layout is important. To withstand the high voltages (10's KV) physical separation is required and to carry the current, substantial tracks are required.
If I will be applying this to appliances, how will I prevent damaging them due to power surge? I'm doing this for a thesis project so really cant make use of devices already made.,Please help me out here.
can you please illustrate how the arduino , relay shield , wires and hardware are connected to each other and to the controlled lights ??
The arduino, relay shield and bluetooth boards just plug together as shown.<br> <br> Match up the size of the board multi-pin headers at the end of the boards, one side has an 8pin connector, the other a 6 pin connector. They won't line up if you turn the boards around the wrong way.<br> <br> As for the wiring, see where the two wires are shown leaving the top board, these are wired directly across the existing switch.<br> <br> Now depending on how your house is wired, there may be 2 or 3 or more wires at the switch as the switch is sometimes used as a junction for power going to other switches. Which is why you should get an electrician to do the wiring.<br> <br> However the switch should be clearly marked as to which two terminals are connected when the switch is closed. These terminals should already have wires in them switching the light.<br> <br> You need to remove one of these existing wires and twist it with one of the wires from the relay board (it does not matter which wire from the relay board you choose) and then put these two wires back into the terminal and screw them down. Then remove the wire from the other side of the switch and twist it together with the remaining wire from the relay board and put them back into the terminal and screw then down. Finished.<br> <br> But remember there is now deadly high voltage on the relay board, which is why is should be mounted in an insulated box so you don't accidentaly touch the terminals<br> <br> As I said above, all this work should be done by a licensed electrician so you don't kill yourself or short something out or start a fire.
if you can put a video or tutorial for this or even a link to an existing (tutorial or video) illustrating this :)
Sorry no video at the moment

About This Instructable




More by drmpf:High Accuracy Remote Data Logging using Mulitmeter/Arduino/pfodApp Remote High Speed Data Logging using Arduino/GL AR150/Android/pfodApp Adafruit WICED Code Generator 
Add instructable to: