Controlling Appliances From Smartphone





Introduction: Controlling Appliances From Smartphone

About: An electronics hobbyist

We all have switched on lights,fan and other appliances using Bluetooth as a for low range applications. Now we are going to look over controlling appliances using WiFi. Now we are restricted here to local WiFi only but you can host your IP on any site like 000webhost etc. to control it from anywhere from the world.Here we are going to learn that.

We would mainly understand here the working of the WiFi to switch on off appliances and the working of relay that we are going to use. NodeMCU will be here the brains of the organisations.It has inbuild WiFi capabilities. You can learn more about it in any instructables or YouTube video.So I'm not going into here its hardware here.

Step 1: Parts Required

1. NodeMCU with USB cable

2. 1 5V Relay module

3. Load..I'm here using 9V LED

4. 100ohm resistor optional

5. Breadboard

6. 9V supply

7. wires

8. Multimeter

Step 2: Working of the WiFi and the Relay

The NodeMCU here connects with our router and creates a local IP.When we open that IP in our smartphone or Laptop( connected over the same router) we will see a webpage with buttons( or as you may develop in the code..we will come soon there).Then there we can turn on or turn off appliances.Now by hosting your IP you can control it anywhere around the world.But here we are restricted to local WiFi and IP only.

Now NodeMCU is a 3.3V device and it cannot drive anything that requires more than 3.3V. So here comes the relay. An electromagnetic relay is nothing but a electromagnetic switch.The COM of Relay Switch is initially connected with NC( NC and COM are thus shorted) when the input coil receives no voltage. When ever the input coil receives 5V or 3.3V it becomes energized and by mutual induction the relay switch moves from NC to NO.Now COM and NO becomes shorted. So if a load is attached keeping COM-NO as a switch, voltage appears over the load whenever the input coil receives voltage.Otherwise no voltage appears across the load when the input coil does not receive logic level 1( 3.3 or 5V).So two isolated circuits can be switched on and off with relays but it is always good to test it beforehand.

Now one thing..many relays have the inverse logic ...that is...if given LOW output from UNO only then the relay gets activated. This is due to different making of the relay circuit. My relay works with +ve trigger. Your relay can be different .So test it( method described in the next step) before using it.

Relay are of many types,like electromagnetic relay,solid state relay,etc. Here we are concerned with cheapest electromagnetic relay only.You can also opt for Solid state relay if you wish or if you have it.

See the pics attached here for more details.

You can check this out

Step 3: Connections and Testing

Now see the above pic and connect as given. Here we are using a 9V light as load, now a relay can handle AC appliances as well but here We are concerned about safety we are taking 9V device.

For testing the Relay( if it is at all good) we just put a 100/330 ohm load across the relay output, supply power ( just replace the light in the pic with resistor and rest is the same) and put the multimeter probes across the resistor.Power up the relay module.Now put the IN wire at 3.3 V of NodeMCU ( Here in the pic there is UNO, but it will work same with NodeMCU..don't worry). You will see the green light of the relay module ON and there is 9V at the multimeter screen. This is just done for the test of the Relay.

Check if inverse logic is applicable with your relay or not...that is output high when given LOW from UNO.

Step 4: Uploading Code and Test It

Now if your relay is at all okay then upload the code attached here to the NodeMCU. Change your ssid and pass of your router at the beginning of the code. then upload.

See the video if you are using for the first time. After uploading open the serial monitor and copy the URL. Now open up a browser and search for that URL. You will come with a screen as given in the pic attached.Now you can switch on and off the lights. As always you can always add more devices along with more relays and change the code as your need.You can open with laptop or mobile which are connected to the same router as that of the NodeMCU is connected.

So now you are familiar with carry on with your automation project.Please comment down for any problems.



    • Creative Misuse Contest

      Creative Misuse Contest
    • Water Contest

      Water Contest
    • Clocks Contest

      Clocks Contest

    9 Discussions

    bro..enter your ssid and pass of your router the starred areas, at the beginning of the code

    2018-03-16 20_47_49-HelloServer1234 _ Arduino 1.8.5.png

    hey man you had set baudrate in the serial monitor at 9600...set it to 115200 then press rst on nodemcu and then see

    If you plan on installing the NodeMCU somewhere semi-permanently, how will you power it?

    1 reply

    I would like to power the nodemcu with a good 9V battery (eg Duracell or any good company.. Not the Chinese cheap ones) or with a Li battery( with voltage rating greater than 5V but less than 12V) along with protection circuit( protection circuit is mandatory for Li batteries).


    9 months ago

    I realize that these days everybody would love to have their homes automated via computers and smart phones. But aren't you the least bit worried that anything you can control over such devices can also be hacked by other knowledgeable folks as well? If you don't go on the net or use smartphones to control things, nobody else can either. Just a thought. But I also like to see people venture into such things and understand how such things actually work.

    3 replies

    i agree with you people need to implement some security in there home automation system and that what i am doing now and will post about it soon

    Yes absolutely that is necessary..please also share your thoughts about this

    Yes that actually is...greater is the connectivity greater is the chance of being hacked...we should also think of solutions in parallel with for example we can create a password box after opening the site(where we will be controlling the things)