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();
}