ESP8266 stops responding when isolated relay is connected to AC tubelight I'm completely new to Arduino and do not have an electronics background.
I'm really keen to do a POC on home automation. As a start, I decided to switch on a tube light using ESP8266, Arduino Uno R3 and isolated relay. I have read that this can be done without arduino also.
I'm able to switch on and switch off the relay without any problem. But when the relay is connected to the tube light, the ESP8266 stops responding. I couldn't find what was causing the issue.
I also read that the ESP2866 should be powered properly to function correctly. I'm following the wiring schema 5 mentioned in the link http://yaab-arduino.blogspot.in/2015/03/esp8266-wiring-schemas.html.

This is my code.
#include &lt;SoftwareSerial.h&gt;

#define DEBUG true
int relay = 8;
SoftwareSerial esp8266(2, 3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
// This means that you need to connect the TX line from the esp to the Arduino's pin 2
// and the RX line from the esp to the Arduino's pin 3
void setup()
{
  Serial.begin(9600);
  esp8266.begin(115200); // your esp's baud rate might be different
  pinMode(relay, OUTPUT);
  digitalWrite(relay, LOW);

  sendData(&quot;AT+RST\r\n&quot;, 2000, DEBUG); // reset module
  sendData(&quot;AT+CWMODE=3\r\n&quot;, 1000, DEBUG); // configure as access point
  sendData(&quot;AT+CWJAP=\&quot;xxxx\&quot;,\&quot;xxx\&quot;\r\n&quot;, 5000, DEBUG); // configure as access point

  sendData(&quot;AT+CIPMUX=1\r\n&quot;, 1000, DEBUG); // configure for multiple connections
  sendData(&quot;AT+CIPSERVER=1,80\r\n&quot;, 1000, DEBUG); // turn on server on port 80
  sendData(&quot;AT+CIFSR\r\n&quot;, 5000, DEBUG); // get ip address
  sendData(&quot;AT+CIFSR\r\n&quot;, 5000, DEBUG); // get ip address
}

void loop()
{
  if (esp8266.available()) // check if the esp is sending a message
  {

    if (esp8266.find(&quot;+IPD,&quot;))
    {
      delay(1000);

      int connectionId = esp8266.read() - 48; // subtract 48 because the read() function returns
      // the ASCII decimal value and 0 (the first decimal number) starts at 48

      if (esp8266.find(&quot;==&quot;))
      {
        Serial.print(&quot;State : &quot;);
        char c = esp8266.read();
        Serial.print(c);
        if (c == '1') {
          digitalWrite(relay, HIGH);
        }
        else {
          digitalWrite(relay, LOW);
        }
      }
      String webpage = &quot;A&quot;;

      String cipSend = &quot;AT+CIPSEND=&quot;;
      cipSend += connectionId;
      cipSend += &quot;,&quot;;
      cipSend += webpage.length();
      cipSend += &quot;\r\n&quot;;

      sendData(cipSend, 1000, DEBUG);
      sendData(webpage, 1000, DEBUG);


      String closeCommand = &quot;AT+CIPCLOSE=&quot;;
      closeCommand += connectionId; // append connection id
      closeCommand += &quot;\r\n&quot;;

      sendData(closeCommand, 3000, DEBUG);
    }
  }
}


String sendData(String command, const int timeout, boolean debug)
{
  String response = &quot;&quot;;

  esp8266.print(command); // send the read character to the esp8266

  long int time = millis();

  while ( (time + timeout) &gt; millis())
  {
    while (esp8266.available())
    {

      // The esp has data so display its output to the serial window
      char c = esp8266.read(); // read the next character.
      response += c;
    }
  }

  if (debug)
  {
    Serial.print(response);
  }

  return response;
}

The above code works perfectly until I connect the tube light to the relay.
The power supply used in 9v 1A wall adapter.
The relay used is http://www.amazon.in/gp/product/B00LL0M6RS?psc=1&amp;redirect=true&amp;ref_=oh_aui_detailpage_o03_s00.
The v+ of the relay is connected directly to the wall adapters voltage and ground to ground of wall adapter. The input of the relay is connected to Arduino digital pin 8.
I'm really struggling hard to proceed here. Any help or hint would be much appreciated.
Thanks in advance.
I suspect that you've connected the relay wrong. I think that the LNP of the relay is supposed to be connected to D8 and the v+ to 5/3.3V and GND to GND....