Introduction: HOME AUTOMATION (CONTROL YOUR APPLIANCES FROM ANY CORNER OF THE WORLD).
In this instructable I have shared how you can use ESP8266 to control AC appliances like Lights, fan, etc. from around the world over Internet via Blynk app.
If you are new to ESP8266 make sure check out this instructable :-
So lets get started...
Step 1: WHAT YOU NEED :-
Step 2: SETTING BLYNK APP :-
* First head to playstore or App store and download Blynk app.
* Next signup with Blynk and you will be redirected to the project page.
* Select "New Project".
* On the next page name the project "Automation".
* Now go to the drop down menu of "Choose Device" and select "NodeMCU" .
* Below that you will find another menu, select "WiFi". Now hit Create.
* An Authentication token will be sent to your email. we will need this token later.
* Now a blank canvas will appear , where you have to add 4 buttons.
* To add buttons goto the top right corner and select + symbol , a menu will appear , select button from that menu.
* You can drag the buttons by a long press/touch and place them where you want.
* Now select first button and a settings menu will appear. you can name the button something is you want.
* Select the output to D0 for 1st button (for other buttons select D1,D2,D3 respectively).
* Now change the Mode to Switch.
* Press the back arrow to save the settings and go back to the canvas.
* Follow the settings for other buttons too.
Refer to the photos for detail.
Step 3: CODING :-
Before getting started first download and install the IDE and Blynk library, for more information check out my previous instructable Here.
Once everything is setup. Just head to :
Files >> Examples >> Blynk >> Boards_WiFi >> ESP8266_Standalone.
Now copy the Authentication token from your mail and paste it in the code.
Add your wifi name and password .
Now Connect the ESP board to the PC and upload the code.
Step 4: CONNECTIONS :-
NOTE :- Work with AC only if you know what you are doing. If you are new and have no idea about Alternating current, take help from someone with experience. I shall not be responsible if you messed up something.
Now lets take a look at the relay module. There are 2 vcc pins. one to power up the circuit. and other to power up the Relays. You can power it with +5v if you are using Arduino. But with NodeMCU you will have to supply separate power.
There is a GND pin which will be connected to the GND of the MCU.
And then there are 4 IN pins which will be connected to the IO pins to toggle the relay.
* First place the NodeMCU on the breadboard.
* Connect the GND pin to -ve rail of the breadboard. Now to power up the MCU you can either connect Vin pin to +5v or power it through USB.
* Now connect the vcc of the relay board to +ve rail of the bread board and GND to -ve rail.
* Now follow the connections from NodeMCU to Relay as follows :-
D0 = IN1
D1 = IN2
D2 = IN3
D3 = IN4
After this connection is done, its time to connect the appliance you want to control to the relay.
Each relay has 3 terminals. the center on being common and other two are normally open and normally closed, For this project we will use normally open terminal (Check the picture to identify)
Here I have connected a light bulb to the relay. I connected two wires to a plug and other end to a bulb holder. then I used a tester to check which terminal is the live one and cut the live wire (AFTER REMOVING THE PLUG FROM THE SOCKET)
Then I connected one end to the common terminal and other end to Normally open terminal. and the set up was done.
Now plug it in and make sure the relay module is not on any conductive surface. also do not touch the module while it is switched on.
Step 5: TESTING :-
To test the setup, Power up the circuit with 9v battery or you can use breadboard power supply. After powering up the NodeMCU it will connect to you WiFi.
Now open the Blynk app and press the play button on the top right corner.
Now toggle the buttons and you will hear a click sound which indicated the relays are switching. also you will notice corresponding LED turn on.
Now you can hook up different appliances and automate your home.
Hope the Instructable is easy to understand, If you face any problem feel free to ask in the comments.