Home Automation With ESP8266 WiFi Without Using Blynk!

46,477

266

49

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.

*** If you like this project, please like, share and VOTE***

Step 1: Next in Home Automation

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!!!

Step 2: Why ESP8266?

Now you might be thinking why I'm using WiFi here? I would have used Bluetooth or RF but why just Wifi with the 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.

Step 3: Which ESP Module I Should Buy?

Now there is a new question raised here Which ESP8266 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 the cheapest one so if you are a beginner to IoT, then you better go for this. The module you should buy depends on how many gpio (general-purpose-input-output) pins you need. This will decide how many things you would be able to control through WiFi. For beginners I would recommend ESP-01 module.

Step 4: Some Basic Info on WIFI!!!

WiFi is a technology that allows electronic devices to connect to a Wireless LAN (WLAN) network, mainly using 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 networking technology that uses radio waves to provide wireless high-speed Internet and network connections. A common misconception is that the term Wi-Fi is short for "Wireless Fidelity", however this is not the case. Wi-Fi is simply a trademarked phrase that means IEEE 802.11x.

Step 5: No Blynk!!!

You can find Home Automation with esp8266 all over the Instructables but a common thing is that they control their esp through Blynk app. Well, Blynk app is also a good thing for the ESP but there are still some 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 well as the Esp would have to connect to a WiFi Hotspot.


So, people who don't have a permanent net connection or a router as a hotspot cannot use the Blynk app.

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

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 directly resulting into fast reaction of the ESP.

Step 7: Gather All Parts

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

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 Breadboard Friendly.

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

Step 9: The Android Application

For controlling the ESP8266 directly from your mobile phone, I've created an app using MIT app inventor. You can 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 in the app. In my case, it was 192.168.4.1

Step 10: TIME TO START BUILD!!!

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

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

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.

Step 12: Connect FTDI to Esp!!!

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

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

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------------GROUND
3.3v ---------------- CHP_PWD(CHIP POWER DOWN)

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

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

Step 14: Flash Your ESP

Flash your ESP to the latest firmware.

Download the necessary software.

Flasher.exe

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

Download the files . >>>>>The files would be in zip file so unzip them and open the esp8266_flasher.exe>>>>>You can use the .bin firmware already provided in the zip file.>>>>>Then select your COMMUNICATION (COM) PORT, and enter 0x00080 in the other column.>>>>>>> Hit Download.

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

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

  • Go to Arduino IDE
  • Go to serial monitor
  • Select baud rate 115200
  • Now 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.

Step 16: Pre-Coding

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



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

http://arduino.esp8266.com/package_esp8266com_inde...


4. Go to TOOLS >>>>> BOARD >>>>> BOARD MANAGER

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

6. Install that ESP8266 PACKAGE.

Step 17: Time for Coding!

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.

Step 18: Make the Circuit!!!

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!!!***

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***

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

Let's say you want to control your light and fan of your bedroom, you can install this circuit on the switch board. Just open the switch board that controls your lights and fans and you will find that two wires are attached to the switch. Just remove those wires from switch and connect them to the PCB terminals and you're done. Super Simple yet Efficient.

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

Step 21: TroubleShooting!@#$%

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 you have to download them first.
  • Make sure that the Connections are correct. Using the continuity function of your multimeter check for 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 ***

Step 22: Check These Points!!!

  • Before testing the circuit, double check all connections with continuity function of multi meter for any wrong connections or short circuits.
  • Install the diode between the coils in correct polarity as it will protect our circuit from any reverse current.
  • 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.

Step 23: What's Happening Here???

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

When you press the button ON on the WiFi controller app, it sends a signal ON to the ESP. The module is programmed in such a way that when it receives the ON signal, it turns it's gpio state to HIGH. By doing so, the relay gets activated and so the appliance turn ON. In the same way when you press OFF, the esp turns it's gpio state to LOW, and so the relay turns off so the appliance. The working principle is very simple as compared to the complication in Blynk app.

If you want more info check GreatScott's tutorial on this.

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

Step 24: Conclusion!!!

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

Thanks for reading,

YAVNIK SHARMA

Share

    Recommendations

    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Party Challenge

      Party Challenge
    • Woodworking Contest

      Woodworking Contest

    49 Discussions

    0
    None
    Mann572017

    Tip 5 weeks ago

    Hi, You don't need to flash upgrade the ESP8266 when programming the chip with Arduino IDE.
    The AT firmware will be completely erased/overwritten by the Arduino IDE.
    If you want to test the AT commands try 115200 or 9600 baudrate. My modules are using different speed.
    Is it possible to share the source code for the Android app ?.

    0
    None
    bhavya p

    Question 3 months ago

    I'm working with wifi esp8266 with arduino after flashing we are unable to get OK in serial monitor could you please help to get this

    0
    None
    Newbie88A

    Question 4 months ago

    Hi Yavnik, great tutorial..I did follow it step by step however, its not functioning correctly for me..I was able to find the ESP8266 board in Arduino with library..I do have a FTDI converter which has a switch on the side to slide so you can run the wifi module in normal mode or in program mode..uploading the firmware with that tool works fine..even though its address 0x00080 was at first a bit strange to me since all the others I was reading about use 4 different addresses however, they don't work either..once the firmware was uploaded I did upload the .apk to my android phone successful..then I try on the wifi module some AT commands, still bening connected to the FTDI and PC..but they don't work in the programming mode..so I unplug the FTDI, slide the switch to normal mode and plug it back into the PC..now I can use the AT commands..this way I also can connect my android phone to the module via wifi..it shows "connected but no Internet"..which is fine since we don't need the Internet..however, when unplugging the wifi module from the FTDI and putting it onto the relay board I also can connect my phone to it..I then open up the App from you, plug the IP of 192.168.4.1 (which I did set in the AT commands) and try using the App..just to find out that it won't do anything..there is no change of poweroutput..the relay module I have has 3 connections for the relay..1 is NC-for normal closed this one could go to an LED..the other one is NO for normal open which also could go to an LED..and the other one is common, there goes the power in..now depending on where we connected the ohter powerlead and press a button on the App the LED should either turn on or off..it just doesn't work at all..I have even tried to change the Bauderate on the wifi module from 115200 back down to 9600 but it won't let me do that..could it be that the relay board needs a Baudrate of 9600 and the wifi module communicates at 115200..so when you upload the firmware it needs 115200 and afterwards we would need to change it to 9600..just that it won't let us do that..at least I don't know a way..can you help me to figure out the problem why the App is not turning the LED on or off?
    Thank you so much for your time..
    NHG

    IMG_20190106_102614.jpgIMG_20190106_102628.jpgIMG_20190106_102704.jpg
    0
    None
    lakshminarayanans

    5 months ago

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

    I do not have Ardiuno.

    0
    None
    solangi01

    1 year ago on Step 23

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

    2 replies
    0
    None
    ashiklalmsolangi01

    Reply 1 year ago

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

    any solutions...

    0
    None
    ashiklalm

    1 year ago

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

    solutions ???

    1 reply
    0
    None
    AliA430ashiklalm

    Reply 9 months ago

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

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

    {

    digitalWrite(LED1, HIGH);

    }

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

    {

    digitalWrite(LED1, LOW);

    }

    0
    None
    AliA430

    9 months ago

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

    0
    None
    pa7x

    Question 1 year ago

    Hi Yavnik hope you are well. Is it possible you send me the source code for Android ? I would like to convert it for iphone/ios also. Thanks in advance. Best regards, Jan

    0
    None
    didiersee

    Question 1 year ago

    Hello I can not load the bin file with the flash, I'm under Windows 10 could you help me

    0
    None
    ronnelsecusana21

    Question 1 year ago on Step 9

    hi i am trying to develop a project like this in fact i already made one but i got one problem i dont have my own app i use to use the Socket Control app that i downloaded to google play it works with my project. but your app isn't here is my code why s it not functioning? can you provide a block for this
    ?
    volatile char MY_DATA1[60];
    volatile unsigned char k1 = 0,CC1=0,RX1 = 0,D = 0;
    void setup()
    {
    // relay out put pin control.//
    pinMode(A0,OUTPUT);
    pinMode(A1,OUTPUT);
    pinMode(A2,OUTPUT);
    digitalWrite(A0,LOW);
    digitalWrite(A1,LOW);
    digitalWrite(A2,LOW);

    // Initial setup //
    Serial.begin(9600);
    // Initial ESP8266 //
    ESP8266_INIT();
    }
    void loop()
    {
    // receive data from ESP8266 //
    if(Serial.available())
    {
    MY_DATA1[k1] = Serial.read(); // read receive data from wi-fi module.
    CC1 = MY_DATA1[k1];
    if(CC1 == ':')D = k1;// check weather data scan start or not.
    k1++;
    if(CC1 == '\n'){k1=0;RX1 = 1;} // chaeck new line character are receive or not.
    }
    // Processing data which are receiving from ESP8266 //
    if(RX1 == 1)
    {
    if(MY_DATA1[D] == ':')
    {
    MY_DATA1[D] = '0';
    if(MY_DATA1[D+1] == 'F')
    {
    MY_DATA1[D+1] = '0';
    if(MY_DATA1[D+2] == 'A')//switch 1 on
    {
    MY_DATA1[D+2] = '0';
    digitalWrite(A0,LOW);
    RX1 = 0;
    }
    else if(MY_DATA1[D+2] == 'B')//switch 1 off
    {
    MY_DATA1[D+2] = '0';
    digitalWrite(A0,HIGH);
    RX1 = 0;
    }
    else if(MY_DATA1[D+2] == 'C')//switch 2 on
    {
    MY_DATA1[D+2] = '0';
    digitalWrite(A1,LOW);
    RX1 = 0;
    }
    else if(MY_DATA1[D+2] == 'D')//switch 1 off
    {
    MY_DATA1[D+2] = '0';
    digitalWrite(A1,HIGH);
    RX1 = 0;
    }
    else if(MY_DATA1[D+2] == 'E')//switch 3 on
    {
    MY_DATA1[D+2] = '0';
    digitalWrite(A2,LOW);
    RX1 = 0;
    }
    else if(MY_DATA1[D+2] == 'F')//switch 1 off
    {
    MY_DATA1[D+2] = '0';
    digitalWrite(A2,HIGH);
    RX1 = 0;
    }
    else if(MY_DATA1[D+2] == 'G')//switch 1 on
    {
    MY_DATA1[D+2] = '0';
    digitalWrite(A0,LOW);
    digitalWrite(A1,LOW);
    digitalWrite(A2,LOW);
    RX1 = 0;
    }
    else if(MY_DATA1[D+2] == 'H')//switch 1 off
    {
    MY_DATA1[D+2] = '0';
    digitalWrite(A0,HIGH);
    digitalWrite(A1,HIGH);
    digitalWrite(A2,HIGH);
    RX1 = 0;
    }
    }
    }
    RX1 = 0;
    }

    }
    void ESP8266_INIT()// initializing wi-fi module.
    {
    Serial.println("AT");// check AT mode.
    delay(1000);
    Serial.println("AT+RST");//RESET module.
    delay(3000);
    Serial.println("AT+CWSAP=\"Home Automation\",\"capstone\",3,2");//set the ssid and password.
    delay(1500);
    Serial.println("AT+CWMODE=3");// set ESP8266 in MODE 3 (Both mode AP+station).
    delay(1400);
    Serial.println("AT+CIPMUX=1");// set ESP8266 in MUX 1 (allow multiple connection).
    delay(1400);
    Serial.println("AT+CIPSERVER=1,80");// start communication ESP8266 on PORT80.
    delay(1500);
    }




    0
    None
    brpbharath

    Question 1 year ago on Step 18

    What about switches and ascilator

    1
    None
    NileshD18

    1 year ago

    hello sir!

    during step 14 can i plug the the ATMEGHA IC?

    i can not able to flash the esp!

    0
    None
    Ramesh Ahir

    1 year ago

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

    0
    None
    LUIZ CARLOSM6

    1 year ago

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

    0
    None
    SteveT142

    1 year ago

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