Node Mcu goes offline randomly

Hello

        I'm using three Nodemcu's for my home automation and these much it works fine. But from last week one of the Nodemcu giving trouble as it suddenly goes offline and within a minute it comes back online and it turns on some relay output high within a fraction of seconds. So at that time my Garage door is automatically opening due to the Triggering. 

Other Nodemcu is working fine as that one doesn’t even disconnect and both of them are in same place.

I thought the there must be an issue with the node and I even replaced to a new one even though the same is happening. Goes offline and randomly turns on relay.

Don’t know what might be the issue
I have uploaded the Pic below.

At a guess, I’d say that it’s probably either a power supply issue or bad coding.

It’s impossible to help further without more information.

The issue with the relay energising at startup could be caused by using Digital datastreams rather than Virtual, a poor choice of GPIO for the relay, or poor coding.

Pete.

Oh ok got it. I’ll check the Power supply as I changed it before a week only as the old one Was dead.

But I tried coding with Virtual pin but my device isn’t changing to online mode. Is there any other Coding for it ?

I’m afraid my psychic powers are a bit depleted today. Maybe posting your code and serial output (correctly formatted with triple backticks of course) would help me to understand what this means.

Pete.

1 Like

I have attached the Code below.

#define BLYNK_PRINT Serial


#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "Auth token";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Nishok_EXT";
char pass[] = "9444902399";

void setup()
{
  // Debug console
  
  Serial.begin(9600);
  pinMode(05, OUTPUT);
  pinMode(04, OUTPUT);
  pinMode(00, OUTPUT);
  pinMode(02, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(15, OUTPUT);
  digitalWrite(05, HIGH);
  digitalWrite(04, HIGH);
  digitalWrite(00, HIGH);
  digitalWrite(02, HIGH);
  digitalWrite(14, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(13, HIGH);
  digitalWrite(15, HIGH);

  Blynk.begin(auth, ssid, pass);
}
BLYNK_WRITE(V1)
{
  if (param.asInt() == 1)
  {
    digitalWrite(05, HIGH);
  }
  else
  {
    digitalWrite(05, LOW);
  }
}
BLYNK_WRITE(V2)
{
  if (param.asInt() == 1)
  {
    digitalWrite(04, HIGH);
  }
  else
  {
    digitalWrite(04, LOW);
  }
}
BLYNK_WRITE(V3)
{
  if (param.asInt() == 1)
  {
    digitalWrite(00, HIGH);
  }
  else
  {
    digitalWrite(00, LOW);
  }
}
BLYNK_WRITE(V4)
{
  if (param.asInt() == 1)
  {
    digitalWrite(02, HIGH);
  }
  else
  {
    digitalWrite(02, LOW);
  }
}
BLYNK_WRITE(V5)
{
  if (param.asInt() == 1)
  {
    digitalWrite(14, HIGH);
  }
  else
  {
    digitalWrite(14, LOW);
  }
}
BLYNK_WRITE(V6)
{
  if (param.asInt() == 1)
  {
    digitalWrite(12, HIGH);
  }
  else
  {
    digitalWrite(12, LOW);
  }
}
BLYNK_WRITE(V7)
{
  if (param.asInt() == 1)
  {
    digitalWrite(13, HIGH);
  }
  else
  {
    digitalWrite(13, LOW);
  }
}
BLYNK_WRITE(V8)
{
  if (param.asInt() == 1)
  {
    digitalWrite(15, HIGH);
  }
  else
  {
    digitalWrite(15, LOW);
  }
}
BLYNK_CONNECTED()
{
  Blynk.syncAll();
}


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

It seems like you’ve taken the Edgent example and hacked-out all the important bits, then added-in most of what should be needed to get your device online.

However. You’ve left this…

Instead of using the required Blynk.run(); line of code.

You’re also missing the three lines of firmware configuration from the Device > Device Info screen and when you add that in you should change this…

to this…

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

You can also delete this…

and this…

It’s also a bad idea to use Blynk.syncAll() for the reasons described at the end of this post…

Next time it would be better if you started with a non-Edgent example!

Pete.

Hey pete,
The problem is solved finally with the corrections you have to told to do and its been working fine for a week. thanks to you and I’ll paste the program aferwards

1 Like