Nodemcu stays in connect but it get divice offline within a day

Sir, How can i pair blynk.begin with wifimanager?
Please give some examples for me to understand easily.

Sir,Instead of showing me nodemcu in the 𝐁𝐎𝐋𝐃 text next to blynk version, it is showing me ESP8266. Will it cause trouble?

What board type do you choose in the IDE when you compile the code?

Pete.

Sir, im using nodemcu.
Can you please check the last coding i sent?

Thank you.

Which NodeMCU type do you choose in the IDE?

Pete.

I selected type nodemcu 1.0 that only supports. Others didnt support as far as i can tell.

Thank you.

What ESP8266 Core version are you using?

Pete.

![20210819_102012|375x500](upload://pMzRsmDddyDw1NW94qyuiarM3mo.jpeg

A couple of pieces of advice…

  1. if you don’t understand the question then try searching this forum to see what it means, and if that doesn’t help then try searching the internet.

  2. if you need to post a screenshot (which in this case you don’t) use the Windows Sniping Tool or the newer Snip and Sketch tool to capture the relevant portion of the screen, rather than taking a photograph of your monitor.

Pete.

Bro listen carefully, you create complex code for simple task.
You don’t need to do anything with these functions if you want permanent mcu.

  1. serial print
  2. Wifi managing
  3. blynk managing

if you want correction in code contact me, I have 2 mcu those work seamless over 2 week.
If you really want modification in code stop using Arduino ide use platformio

Ok bro i will try it. the help of everyone is needed.

Hi bro
my device after 3 mounth again and again getting to offline plz help me and relace my coding.

#include <SoftwareSerial.h>
#define BLYNK_PRINT Serial

//#define BLYNK_MAX_SENDBYTES 128
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char ssid[] = "xxxxxxx";
char pass[] = "xxxxxxxx";

char auth[] = "xxxxxxxxx";

#define BLYNK_PRINT Serial


int val = 0; 
int pirState;
int x = 0;
WidgetLCD lcd(V1);
WidgetLCD lcd2(V5);
WidgetLCD lcd3(V7);
int ReCnctFlag;  // Reconnection Flag
int ReCnctCount = 0;  
BlynkTimer timer;

void initWiFi() {
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);
  Serial.print("Connecting to WiFi ..");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print('.');
    delay(1000);
  }
  Serial.println(WiFi.localIP());
}

BLYNK_WRITE(V0)   
{

  if(param.asInt() == 0){
    pinMode(D0, LOW);
      lcd.print(0, 0, "SWITCH 01 OFF"); 
  }else{
     pinMode(D0, HIGH);
      lcd.print(0, 0, "SWITCH 01 ONN"); 
  }
   
}

BLYNK_WRITE(V2)   
{

  if(param.asInt() == 0){
    pinMode(D1, LOW);
     lcd.print(0, 1, "SWITCH 02 OFF"); 
  }else{
     pinMode(D1, HIGH);
      lcd.print(0, 1, "SWITCH 02 ONN"); 
  }
   
}

BLYNK_WRITE(V3)   
{

  if(param.asInt() == 0){
    pinMode(D5, LOW);
  lcd2.print(0, 0, "SWITCH 03 OFF"); 
  }else{
     pinMode(D5, HIGH);
 lcd2.print(0, 0, "SWITCH 03 ONN"); 
  }
   
}

#define pirPin D4               
int pirValue;   
char replybuffer[255];             
int pinValue;  
SoftwareSerial sim(10, 11);
int _timeout;
String _buffer;

BLYNK_WRITE(V4)   
{
  
  if(param.asInt() == 0){
    pinMode(D3, LOW);
     lcd2.print(0, 1, "SWITCH 04 OFF"); 
  }else{
     pinMode(D3, HIGH);
      lcd2.print(0, 1, "SWITCH 04 ONN"); 
  }
   
}

BLYNK_WRITE(V6)   
{
 pinValue = param.asInt();    
  if(param.asInt() == 0){
    lcd3.clear();
     lcd3.print(0, 1, "HUMAN OFF"); 
  }else{
      lcd3.print(0, 1, "HUMAN ONN"); 
  }
   
}

BLYNK_CONNECTED(){
  Serial.println("Cconnected");
  Blynk.syncAll();
  ReCnctCount = 0;
}

int calibrationTime = 30;
long unsigned int lowIn;
long unsigned int pause = 5000;
boolean lockLow = true;
boolean takeLowTime;
int PIRValue = 0;

void setup() { 
  
   Serial.begin(9600);
   
  _buffer.reserve(50);
  Serial.println("System Started...");


  pinMode(D0, OUTPUT);
  pinMode(D1, OUTPUT);
  pinMode(D5, OUTPUT);
  pinMode(D3, OUTPUT);

  pinMode(D0, LOW);
  pinMode(D1, LOW);
  pinMode(D5, LOW);
  pinMode(D3, LOW);
 
  pinMode(pirPin, INPUT_PULLUP);
  
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);
  Serial.print("Connecting to WiFi ..");
  
  Blynk.config(auth, "blynk-cloud.com", 8080);
  Blynk.connect();

  lcd.clear(); 
  
  timer.setInterval(2500L, notifiaction);
}

void loop() {
      timer.run();
     if(WiFi.status() != WL_CONNECTED)
     {
       Serial.print("WIFI Reconnecting");
       delay(1000);
       initWiFi();  //  WiFi setup
     }
    else if (Blynk.connected()) 
    {
       Blynk.run();   // If connected run as normal
    } 
   else if (ReCnctFlag == 0) 
   {  
    ReCnctFlag = 1;  // Set reconnection Flag
    Serial.println("Starting reconnection timer in 30 seconds...");
    timer.setTimeout(30000L, []() {  // Lambda Reconnection Timer Function
      ReCnctFlag = 0;  // Reset reconnection Flag
      ReCnctCount++;  // Increment reconnection Counter
      Serial.print("Attempting reconnection #");
      Serial.println(ReCnctCount);
      Blynk.connect();  // Try to reconnect to the server
      });  // END Timer Function
   }  
}

void notifiaction()
{  
  
  if(pinValue){
    int sensor = digitalRead(pirPin);

    if (sensor == 1) {
        Serial.println("WARNING! Please check your security system");
         Blynk.notify("WARNING! Please check your security system");  
        lcd3.print(0, 0, "MOTION DETACTED.."); 

    }else{
       lcd3.print(0, 0, "MOTION  NOT DETACTED.."); 
    }
  }
 
}```

Hi

please any one help me​:cry::cry::cry:

digitalWrite command needs to use in place of pinMode. Start by searching mistakes in the code, and also do not use D3 as may cause problems. Google for usable pins on ESP8266. Choose a pin which is stable.

You’re also creating a SoftwareSerial port using GPIOs 10 and 11
GPIO 10 is a pin that should be avoided where possible (along with GPIO 9), and GPIO 11 is a reserved pin that is not broken out on the ESP8266 chip.
In addition, this SoftwateSerial port called ‘sim’ is never used, as it doesn’t have a serial begin statement and doesn’t appear anywhere in your sketch, so this line of code should be removed, along with this one:

Also, I’d encourage you to place all of your variable declaration statements and #defines together near the top of your sketch, so that you can easily spot any conflicts, rather than having them scattered about your code.

Also, this line is included twice…

Also, you need to have a way to limit your notifications to no more than once every 5 seconds.

If all has been working well for 3 months and you’ve not re-flashed your NodeMCU with fresh code then you should start looking at other issues, such as your WiFi router or ISP.

Pete.