Home Automation With ESP8266 WiFi Without Using Blynk!

20
instructables Home Automation With ESP8266 WiFi Without Using Blynk! by Yavnik Step 1: Next in Home Automation Step 2: Why ESP8266? Firstly, I want to THANK everyone for making me a winner in Automation Contest 2016 for this INSTRUCTABLE. So, as I promised you, here's the instructable for controlling home appliances with ESP8266 WiFi module. In order to stay on the couch and control all electrical appliance with just a TV remote, I created an instructable for that and now it's time to upgrade to WiFi. Now you'll be able to control everything with your smartphone. Sounds complicated!!! But very easy to make!!! Now you might be thinking why I'm using WiFi here? I would have used Bluetooth or RF but why just Wifi with the Home Automation With ESP8266 WiFi Without Using Blynk!: Page 1

Transcript of Home Automation With ESP8266 WiFi Without Using Blynk!

Page 1: Home Automation With ESP8266 WiFi Without Using Blynk!

instructables

Home Automation With ESP8266 WiFi Without Using Blynk!

by Yavnik

Step 1: Next in Home Automation

Step 2: Why ESP8266?

Firstly, I want to THANK everyone for making me a winner in Automation Contest 2016 for this INSTRUCTABLE.So, as I promised you, here's the instructable for controlling home appliances with ESP8266 WiFi module.

In order to stay on the couch and control all electrical appliance with just a TV remote, I created an instructable forthat and now it's time to upgrade to WiFi. Now you'll be able to control everything with your smartphone. Soundscomplicated!!! But very easy to make!!!

Now you might be thinking why I'm using WiFi here? I would have used Bluetooth or RF but why just Wifi with the

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 1

Page 2: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 3: Which ESP Module I Should Buy?

ESP8266? The Simple answer is :

• ESP8266 would be cheaper than Bluetooth module (on eBay, it's just around $2)• By using the ESP8266, you can connect the module to internet and control it from any part of the world.

Now there is a new question raised here WhichESP8266 module I should buy?

Well by now there are many variations of this module.Here in this instructable, I've used ESP-01 module.This was the first module introduced and also thecheapest one so if you are a beginner to IoT, then

you better go for this. The module you should buydepends on how many gpio (general-purpose-input-output) pins you need. This will decide how manythings you would be able to control through WiFi. Forbeginners I would recommend ESP-01 module.

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 2

Page 3: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 4: Some Basic Info on WIFI!!!

Step 5: No Blynk!!!

WiFi is a technology that allows electronic devices toconnect to a Wireless LAN (WLAN) network, mainlyusing the 2.4 gigahertz (12 cm) UHF and 5 gigahertz(6 cm) SHF ISM radio bands.

Wi-Fi is the name of a popular wireless networkingtechnology that uses radio waves to provide wireless

high-speed Internet and network connections. Acommon misconception is that the term Wi-Fi is shortfor "Wireless Fidelity", however this is not the case.Wi-Fi is simply a trademarked phrase that meansIEEE 802.11x.

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 3

Page 4: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 6: Then What's So Special in My System!!!

Step 7: Gather All Parts

You can find Home Automation with esp8266 all overthe Instructables but a common thing is that theycontrol their esp through Blynk app. Well, Blynk appis also a good thing for the ESP but there are stillsome cons.

• Firstly, it requires an internet connection so that the

app can be connected to it's server. • Second, like other methods, the Blynk app as wellas the Esp would have to connect to a WiFi Hotspot.

So, people who don't have a permanent netconnection or a router as a hotspot cannot use theBlynk app.

In my system, I've created an android app which directly connects to your esp instead of connecting to a hotspot.This also requires no internet connection or any external wifi hotspot as the two machines would connect directlyresulting into fast reaction of the ESP.

Here all the parts you would need in this Project are mentioned and the links from where you can buy them but Irecommend that you should first try to find the components locally because this way you could buy them faster andmaybe cheaper but if they are not available locally you can always buy them with the links provided. I always buyeverything from ebay 'cause it's the cheapest. For this project you will need:

ESP8266 WiFi ModuleFTDI Breakout (or ARDUINO UNO)2x 1K Resistors2x BC547 Transistor2x 5v Relay2x 1N4007 DIODE2x Screw Teminals.

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 4

Page 5: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 8: Make It Breadboard Friendly

By now, you may have noticed that the ESP-01 cannot fit on breadboard so we have to make it BreadboardFriendly.

The steps are simple you just have to cut a 4 x 4 dots pcb, solder the male headers and female headers as shownin the pictures above.

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 5

Page 6: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 9: The Android Application

For controlling the ESP8266 directly from your mobile phone, I've created an app using MIT app inventor. You canHome Automation With ESP8266 WiFi Without Using Blynk!: Page 6

Page 7: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 10: TIME TO START BUILD!!!

find the app here.

First you need to connect your smartphone to esp8266 WiFi and then set ip address to your module's ip address inthe app. In my case, it was 192.168.4.1

https://www.instructables.com/ORIG/F5S/N43X/IVO3IAJL/F5SN43XIVO3IAJL.apk…Download

First we have to connect the ESP module to the computer to update the firmware as well as to program it.

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 7

Page 8: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 11: Convert 5v to 3.3v!!!

Step 12: Connect FTDI to Esp!!!

The most importaqnat thing is that the esp8266 module works only with 3.3v and not 5v.

5v can kill it, so in order to convert 5v to 3.3v we have to create a voltage divider.

Create a voltage divider by connecting a 1K and 2K resistor as shown in the pic.

Just follow the schematic to connect your esp to an FTDI breakout. Make sure to use 3.3v only on your FTDIbreakout.

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 8

Page 9: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 13: You Don't Have an FTDI Breakout!

Step 14: Flash Your ESP

If in case you don't have an FTDI breakout just like me, you can also use your arduino to program the esp.

REMOVE THE ATMEGA 328 IC FROM THE ARDUINO BOARD BEFORE PROGRAMMING.

DONT FORGET THAT ESP8266 WORKS ON 3.3v AND NOT ON 5v.

ARDUINO ESP8266

3.3v ---------------- VCC

GROUND------------GROUND3.3v ---------------- CHP_PWD(CHIP POWER DOWN)

TX --------------- TX

RX --------------- RX

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 9

Page 10: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 15: Check If Everything's All Right!!!

Flash your ESP to the latest firmware.

Download the necessary software.

Flasher.exe

Make sure to connect gpio 0 to ground. This willenable the flash mode in your esp.

Download the files . >>>>>The files would be in zipfile so unzip them and open theesp8266_flasher.exe>>>>>You can use the .binfirmware already provided in the zip file.>>>>>Thenselect your COMMUNICATION (COM) PORT, andenter 0x00080 in the other column.>>>>>>> HitDownload.

https://www.instructables.com/ORIG/FL2/CLGA/IVO3BZOP/FL2CLGAIVO3BZOP.zip…Download

After flashing the ESP, it's time to check if everything's all right.

Go to Arduino IDEGo to serial monitorSelect baud rate 115200Now enter the following commands.

AT

After entering this command press SEND and if you recieve OK then you are all set to go.

You can play with the module with other AT Commands as shown in the pics above.

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 10

Page 11: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 16: Pre-Coding

To program the ESP from Arduino IDE, you have toinstall some necesary softwares.

1. Go to Arduino IDE 2. Go to File >>>> Preferences 3. In the text box of ADDITIONAL BOARDSMANAGER URL, copy and paste the path below

rel="nofollow">http://arduino.esp8266.com/package_esp8266com_inde...

4. Go to TOOLS >>>>> BOARD >>>>> BOARDMANAGER

5. Type esp in the searchbox and only one optionwould be left.

6. Install that ESP8266 PACKAGE.

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 11

Page 12: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 17: Time for Coding!

Step 18: Make the Circuit!!!

After installing the ESP8266 Package,

GO TO TOOLS >>>>> BOARDS >>>>> Select the module you have (If you have the esp-01 module like me,select the GENERIC ESP8266 MODULE)

Now change the Properties according to your module in the tools menu.

Now make sure you have the ESP8266WIFI library.

Upload the code to your esp.

https://www.instructables.com/ORIG/FCX/SCY8/IR85H83Y/FCXSCY8IR85H83Y.ino…Download

First try to make the circuit on breadboard and then make it permanent on pcb board.

But the biggest problem is that the ESP8266 needs 3.3v and not 5v.

Don't underestimate the power of 5v, it's enough to kill your ESP module. ***Hey! strucked somewhere???I am always there to help you in the comments below!!!***

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 12

Page 13: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 19: CAUTION!!! HIGH VOLTAGE!!!

WARNING!!!Incorrect or Improper use can lead to:

Serious injuries or Death. Physical Damage to the Product. Creating dangerous Hazards.

***I TAKE NO RESPONSIBILITY OF ANY OF YOUR ACTIONS***

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 13

Page 14: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 20: How to Use This at Your HOME!!!

Let's say you want to control your light and fan of yourbedroom, you can install this circuit on the switchboard. Just open the switch board that controls yourlights and fans and you will find that two wires areattached to the switch. Just remove those wires fromswitch and connect them to the PCB terminals and

you're done. Super Simple yet Efficient.

***Kids, stay away from live electric wires. Have an adultbeside to do the high voltage electric work***

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 14

Page 15: Home Automation With ESP8266 WiFi Without Using Blynk!

Step 21: TroubleShooting!@#$%

Step 22: Check These Points!!!

Step 23: What's Happening Here???

Hmm... Not working as Expected???

Try this Trouble Shooting guide so you can make your project work like a charm!!

First check the code. Make sure that you have all the libraries installed correctly. If not then youhave to download them first.

Make sure that the Connections are correct. Using the continuity function of your multimeter checkfor any wrong connections or short circuits!!!Make sure you have working ESP and relays.Make Sure you have placed the diode in correct polarity.Make sure that you have connected your phone to esp through WiFi.

*** If you have any doubts regarding this you can always ask me in the comments below ***

Before testing the circuit, double check all connections with continuity function of multi meter for anywrong connections or short circuits.Install the diode between the coils in correct polarity as it will protect our circuit from any reversecurrent.I recommend that before testing the circuit with HIGH AC VOLTAGE, first try it with a simple LED.Also never use such appliances that draws more current than your Relay's ratings.

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 15

Page 16: Home Automation With ESP8266 WiFi Without Using Blynk!

builded everything and when sending commands blue led blinks but no output ..

solutions ???

Change the if loops as follows , it'll work perfectly fine:

if (req=="GET /?pin=OFF1 HTTP/1.1")

{

digitalWrite(LED1, HIGH);

}

Step 24: Conclusion!!!

Hmm... confused by now... let me tell you What'shappening here???

When you press the button ON on the WiFi controllerapp, it sends a signal ON to the ESP. The module isprogrammed in such a way that when it receives theON signal, it turns it's gpio state to HIGH. By doingso, the relay gets activated and so the appliance turnON. In the same way when you press OFF, the espturns it's gpio state to LOW, and so the relay turns off

so the appliance. The working principle is very simpleas compared to the complication in Blynk app.

If you want more info check GreatScott's tutorial onthis.

*** If you still have some doubts, feel free to ask in thecomment section below***

Hey!!! Good Luck for creating this on your own. If you are strucked somewhere, feel free to ask me in thecomments sections below. I 'll always be there to help. If you have any suggestions tell it to me, and if you like theproject hit the like button, share the project as fas as you can and please VOTE in the contests.

Thanks for reading,

YAVNIK SHARMA

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 16

Page 17: Home Automation With ESP8266 WiFi Without Using Blynk!

else if (req=="GET /?pin=ON1 HTTP/1.1")

{

digitalWrite(LED1, LOW);

}

Thanks AliA430 !!!!!it worked as charm !

Hi,

Would it be possible to post the source code for the MIT app inventor app?

Thanks

I want app that work through internet

http://arduino.esp8266.com/package_esp8266com_index.json seems to be broken. Don't knowwhy.

I am having FTDI. By connecting the same with ESP as shown by you, is flashing the bin file asgiven with the flasher is sufficient? I will wire relays as shown by you. After that anything need tobe done?

I do not have Ardiuno.

Hi Dear, i upload the file successfly done and i connect the mobile with esp8266 wifi module andsend command via mobile blue led flash short time but no outnput active i connect led and relaybut both are not working. Plz help me what can I do

am also having same problem ,blue led blinks when i click ON/OFF button.But no output tried bothleds and realys.....

any solutions...

Same in my case

I logged in just to tell you thank you Mr.Yavnik Sharma, much regards from Saudi Arabia !

hi, can pls send me aia source code of smartphone Controlled Home Appliance to my [email protected].. thanks..

hello sir!

during step 14 can i plug the the ATMEGHA IC?

i can not able to flash the esp!

Good afternoon i want to make these. can i use relay board?

Good night, can you help me, I downloaded the WifiWebServer code on my ESP8266-01 to usethe two GPIO's to control a double relay, so that's fine, but after some time my ESP8266 stopscommunicating with my network, only going back to work when I take power from it, if you can helpme I'll be grateful, thank you

Can I do this project with a iphone? Thanks for sharing your project.

Sorry, I haven't developed an iOS app for this project yet...

Hi, I am getting

"raise in device connect

chip sync error.Home Automation With ESP8266 WiFi Without Using Blynk!: Page 17

Page 18: Home Automation With ESP8266 WiFi Without Using Blynk!

baudrate sync fail"

this error while trying to flash at firmware through flash tool. Any idea how to solve this?

hi there,

I made it, and now I want to modify the android program, as a start I guess you used socket API,but I don't know how to go on from there.

can you share some kind of source code for the android app, or point me in the right direction tomake my app (I don't want to use app inventor :D ).

thanks in advance

Hello Yavnik,

first of all, congratulations for very nice and useful instructable!

Are you willing to share your appinventor source file for this?

Thank you.

Hi there,I just wanna know I've 3 ESP8266 boards connected to my router.Each board can be accessed by putting their individual IP and thus the corresponding devices canbe controlled.But if I wanna access all the boards simultaneously, what Have I to do for that?? I'm asking this question because the 3 ESPs are controlling each of my room. If I've to control theappliances of my room-1, I need to connect to corresponding ESP8266. For room-2, need toconnect to corresponding ESP8266 and so on. But what if I wanna control all roomssimultaneously.

Any suggestion would be appreciable..

Looks like a job for MQTT.

Hi,

I think you should use other ESP8266 boards like the esp-12 or NODE MCU. By doing so, you'llget access to more GPIO pins and thus you would be able to control more appliances with just 1esp.

If you have any other doubts, you can always ask me by sending a private message or by writinghere at the comments section.

Best Luck for your build,Yavnik Sharma

Can you plz look at this

https://www.instructables.com/community/security-s...

small help thanks

Hi

Can i use ESP8266 to control the setting of any device? For exmple chane the AC temprature. Orit just used for ON/OFF application?.

If i can use it to control can you please tell me how and which program should i use?

Good job! but I still had some problems with this inst. For example if I need to control many devicesand there're separated with some distance,for wireless purpose I had to used many ESP to control

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 18

Page 19: Home Automation With ESP8266 WiFi Without Using Blynk!

then. Under this circumstances, the smartphone&APP had to switch the WIFI connectionfrequency,and that was too inconvenient! Do you have any ideal to solve the problem?

Only 2 IO's is not enough.

Try using I2C, it works on esp8266, so you can control a lot of devices.

Hey great build here !

Help me out on this , after rebooting my ESP-01 (remove power and attach again) the program islost ! What should I do ? TX,RX,RESET are free. GPIO is attached to led , rest connections aresame

the AT command worked, but the code is not getting uploaded. the following is the error messagei'm getting -

warning: espcomm_sync failed

error: espcomm_open failed

error: espcomm_upload_mem failed

error: espcomm_upload_mem failed

.

How can i upload the code?

The flasher is showing ''Leaving...

Failed to leave Flash mode'' after 99% update, what should i do? pls reply, its urgent

No problem! It's the way that flasher works! After uploading just remove the wire that is betweenGPIO pin 0 and ground and reset the module and you're done!!!

IF YOU STILL FACE ANY PROBLEM, FEEL FREE TO CONTACT ME.

how to reset the module? i have connected the reset pin to ground and then taken out, but afterthat when i sent AT command to the module, it didn't respond. How to bring the module to usermode?

To bring the ESP to user mode, just remove the wire between GPIO 0 and ground, turn it off andthen turn it on. If you still face problems with AT commands, make sure you have selected thecorrect bbaudrate in the serial monitor.(Normally it is 9600 or 115200)

it is not responding to AT command at any baud arte even after disconnecting the gpio 0 andrebooting.. Where is the problem?

Where I can buy wifi module cheap in india? and If I need some more output oins can I connect Iwith arduino and use arduinos pins for on and off?

1. Try ebay.in I always buy my module from there.

2. If you need more output pins you can use other popular WiFi boards like NodeMCU or otherboards like that.

I want to connect it with arduino to tx and rx and use its pins

bro i really wanna make this project but m really confused about the coding part......as i am not verygood with ardiunos plzzz help mee.....nd explain it in detail

and also for using this for ac....do i need different relays or the same can be used

i use slack app to control my iot, look weird but its work..

https://www.instructables.com/id/Lumen-Histoire-IoT-App/

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 19

Page 20: Home Automation With ESP8266 WiFi Without Using Blynk!

Awesome!!!

where is an app using MIT app inventor please give me the link

I attached the app that I made in step 9. If you want to make your own app then go tohttp://ai2.appinventor.mit.edu

Great job, will definitely try this. Can't vote on mobile app, but will go on full site to do so. Anotherwinner for you I think. ..

Thanks and Good luck for your build!!!

Home Automation With ESP8266 WiFi Without Using Blynk!: Page 20