BLYNK
HOME       📲 GETTING STARTED       đź“— DOCS       âť“HELP CENTER       👉 SKETCH BUILDER

SmartSwitch disconnected

I am new IoT and I had built a module with Arduino Uno,Esp8266 and 5v Relay. It works fine if I doesn’t connect any load to the relay for hours. Suppose if i connect bulb to relay it works for few seconds and blynk shows SmartSwitch disconnected and it doesn’t works. However if I remove power supply to Ardunio and re-connect again it works for few second and disconnects. Below is the sketch, please advise whether it’s hardware or sketch problem.

#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
char ssid[] = "xxxxxxx" ;
char pass[] = xxxxxxx";


// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&Serial);

#define relay1 13
BLYNK_WRITE(V13)
{
  int relaystatus1 = param.asInt();
  if (relaystatus1 == 1)
  {
    digitalWrite(relay1, HIGH);
    Serial.println(relaystatus1);
  }
  else
  {
    digitalWrite(relay1, LOW);
    Serial.println(relaystatus1);
  }
}

void setup()
{
  Serial.begin(115200);
  delay(10);
  Serial.begin(ESP8266_BAUD);
  delay(10);
  Blynk.begin(auth, wifi, ssid, pass);
  Serial.println("Connected");
}

void loop()
{
  Blynk.run();
}

@rajiv please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

done, Thank you

The Uno has one hardware serial port and this can’t be used for both debugging and communication with your ESP-01.
The normal solution is to use SoftwareSerial to create a second serial port and connect your ESP-01 to this. You’ve included the SoftwareSerial library, but aren’t using it. If you did use it then you’d need to drop your ESP-01’s baud rate to 9600 as the SoftwareSerial library is unreliable at faster speeds.

Pete.

Is dropping Baud rate is the solution or do I need to change the sketch. Please advice I am new to IoT

I’d suggest that you re-read what I’ve written, and search the forum for information about using the Uno/ESP-01 combination.
There is a lot that’s been written about the issues of using this combination and I don’t intend to repeat it.

The better solution would be to use an IoT ready board…

Pete.

Thank you for your support. As you suggested I will go thru forum.