BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Arduino Due + W5500 lost connection without serial cable

I have problems with the connection, the arduino connects to the server only when I open the serial monitor via usb cable on the programming port.
once the connection has started I can disconnect the usb cable and the arduino remains connected.
how can i solve?

You might want to post your code and supply fuller details… else we are just guessing.

Please properly format it as instructed…

Last night I left the device connected and this morning I found it disconnected. As soon as I connected to the PC and opened the serial monitor it was reconnected

   #define BLYNK_PRINT Serial
    #include <SPI.h>
    #include <Ethernet2.h>
    #include <BlynkSimpleEthernet2.h>
    #include <SimpleTimer.h>
    SimpleTimer timer; 
    char auth[] = "xxxxxx";

    WidgetLCD lcd(V1);
    //**************  pin define  Input *****************************
    int inp2 = 2;
    int inp3 = 3;
    int inp4 = 4;
    int inp5 = 5;
    int inp6 = 6;
    int inp7 = 7;
    int inp8 = 8;
    int inp9 = 9;
    //int inp10 = 10; // disable for w5100
    int inp11 = 11 ;
    int inp12 = 12 ;
    int inp13 = 13 ;
    int inp14 = 14 ;
    int inp15 = 15 ;
    int inp16 = 16 ;
    int inp17 = 17 ;
    int inp18 = 18 ;
    int inp23 = 23 ;
    int inp25 = 25 ;
    int inp27 = 27 ;
    int inp29 = 29 ;
    int inp31 = 31 ;
    int inp33 = 33 ;
    int inp35 = 35 ;
    int inp37 = 37 ;
    int inp39 = 39 ;
    int inp41 = 41 ;
    int inp43 = 43 ;
    int inp45 = 45 ;
    int inp47 = 47 ;
    int inp49 = 49 ;
    int inp51 = 51 ;
    int inp53 = 53 ;
    //******** pin define output******************************
    int out22 =22 ; 
    int out24 =24;
    int out26 =26;
    int out28 =28;
    int out30 =30;
    int out32 =32;
    int out34 =34;
    int out36 =36;
    int out38 =38;
    int out40 =40;
    int out42 =42;
    int out44 =44;
    int out46 =46;
    int out48 =48;
    int out50 =50;
    int out52 =52;
    //*************** function define  ************************
    WidgetLED led1(V1);
    WidgetLED led2(V2);
    WidgetLED led3(V3);
    WidgetLED led4(V4);
    WidgetLED led5(V5);
    WidgetLED led6(V6);
    WidgetLED led7(V7);
    WidgetLED led8(V8);
    WidgetLED led9(V9);
    WidgetLED led11(V11);
    WidgetLED led12(V12);
    WidgetLED led13(V13);
    WidgetLED led14(V14);
    WidgetLED led15(V15);
    WidgetLED led16(V16);
    WidgetLED led17(V17);
    WidgetLED led18(V18);
    WidgetLED led23(V23);
    WidgetLED led25(V25);
    WidgetLED led27(V27);
    WidgetLED led29(V29);
    WidgetLED led31(V31);
    WidgetLED led33(V33);
    WidgetLED led35(V35);
    WidgetLED led37(V37);
    WidgetLED led39(V39);
    WidgetLED led41(V41);
    WidgetLED led43(V43);
    WidgetLED led45(V45);
    WidgetLED led47(V47);
    WidgetLED led49(V49);
    WidgetLED led51(V51);
    WidgetLED led53(V53);
    //*************** Controllo uscita e da Blink      *********
    bool connesso = 0;
    BLYNK_WRITE(V22) { if (param.asInt ()&& connesso == 1){ digitalWrite(out22, HIGH);} else{digitalWrite(out22, LOW);}}// 24Volt aux
    BLYNK_WRITE(V24) { if (param.asInt ()&& connesso == 1){ digitalWrite(out24, HIGH);} else{digitalWrite(out24, LOW);}}// pulsante mini pc
    BLYNK_WRITE(V44) { if (param.asInt ()&& connesso == 1){ digitalWrite(out44, HIGH);} else{digitalWrite(out44, LOW);}}// test connessione
    //**********************************************************
    void setup()
    {
      Serial.begin(9600);
      timer.setInterval(10000L, CheckConnection); //Timer per controllo  connessione avvenuta ogni 10 secondi
      
      timer.setInterval(500L, buttonLedWidget); // controllo per connessione avvenuta
    //******************   lcd********************************  
      lcd.clear(); 
     //lcd.print(0,0,"test invio");// ok test scrittura

     
    //****  fine lcd  **************************************** 
    pinMode (inp2 , INPUT_PULLUP);
    pinMode (inp3 , INPUT_PULLUP);
    pinMode (inp4 , INPUT_PULLUP);
    pinMode (inp5 , INPUT_PULLUP);
    pinMode (inp6 , INPUT_PULLUP);
    pinMode (inp7 , INPUT_PULLUP);
    pinMode (inp8 , INPUT_PULLUP);
    pinMode (inp9 , INPUT_PULLUP);
    //pinMode (inp10 , INPUT_PULLUP);  // disable for w5100
    pinMode (inp11 , INPUT_PULLUP);
    pinMode (inp12 , INPUT_PULLUP);
    pinMode (inp13 , INPUT_PULLUP);
    pinMode (inp14 , INPUT_PULLUP);
    pinMode (inp15 , INPUT_PULLUP);
    pinMode (inp16 , INPUT_PULLUP);
    pinMode (inp17 , INPUT_PULLUP);
    pinMode (inp18 , INPUT_PULLUP);
    pinMode (inp23, INPUT);
    pinMode (inp25, INPUT_PULLUP);
    pinMode (inp27, INPUT);
    pinMode (inp29, INPUT);
    pinMode (inp31, INPUT);
    pinMode (inp33, INPUT);
    pinMode (inp35, INPUT);
    pinMode (inp37, INPUT);
    pinMode (inp39, INPUT);
    pinMode (inp41, INPUT);
    pinMode (inp43, INPUT);
    pinMode (inp45, INPUT);
    pinMode (inp47, INPUT);
    pinMode (inp49, INPUT);
    pinMode (inp51, INPUT);
    pinMode (inp53, INPUT);  
    //******  OUT   ************************************************************
    pinMode (out22, OUTPUT);digitalWrite (out22, LOW);
    pinMode (out24, OUTPUT);digitalWrite (out24, LOW);
    pinMode (out26, OUTPUT);digitalWrite (out26, LOW);
    pinMode (out28, OUTPUT);digitalWrite (out28, LOW);
    pinMode (out30, OUTPUT);digitalWrite (out30, LOW);
    pinMode (out32, OUTPUT);digitalWrite (out32, LOW);
    pinMode (out34, OUTPUT);digitalWrite (out34, LOW);
    pinMode (out36, OUTPUT);digitalWrite (out36, LOW);
    pinMode (out38, OUTPUT);digitalWrite (out38, LOW);
    pinMode (out40, OUTPUT);digitalWrite (out40, LOW);
    pinMode (out42, OUTPUT);digitalWrite (out42, LOW);
    pinMode (out44, OUTPUT);digitalWrite (out44, LOW);
    pinMode (out46, OUTPUT);digitalWrite (out46, LOW);
    pinMode (out48, OUTPUT);digitalWrite (out48, LOW);
    pinMode (out50, OUTPUT);digitalWrite (out50, LOW);
    pinMode (out52, OUTPUT);digitalWrite (out52, LOW);
    Blynk.begin(auth);
    Blynk.connect();   
    }
    //***************************************************************************
    void buttonLedWidget(){
    // ingressi  da Arduino to software***************************************** 
    if ( digitalRead (inp5)==0){led5.on();  } else {led5.off();                             }        // Solare on
    if ( digitalRead (inp6)==0){led6.on();  } else {led6.off();Blynk.notify("PLC Stop !!!");}        // PLC Run
    if ( digitalRead (inp12)==0){led12.on();  } else {led12.off();}                                 // antifurto inserito
    if ( digitalRead (inp18)==0){led18.on();Blynk.notify("Allarme Antifurto"); } else {led18.off();}// allarme antifurto

    if ( digitalRead (inp27)==1){;Blynk.notify("Test connessione ok"); }
    }// fine void buttonvidget
    // uscite  da software to arduino*******************************************


    //Blynk.virtualWrite(V1, 0);  // es. per riportare un interruttore off
    //****************************************************************************
    void CheckConnection(){  // controllo connessione e sincronismo generale*****
    bool isFirstConnect = 1; 
      if(!Blynk.connected()){
        Serial.println("Not connected to Blynk server"); connesso = 0;
        Blynk.connect();  // try to connect to server with default timeout
      } else{Serial.println("Connected to Blynk server");connesso = 1;if(isFirstConnect ==1){Blynk.syncAll();isFirstConnect = 0;}}
    }// **********************fine controllo connessione***************************

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

    }

I had the problem of connection even when I was using this:

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet2.h>
#include <BlynkSimpleEthernet2.h>

char auth[] = "xxxxxxxxxxxxxxxxxx";

void setup()
{
 Serial.begin(9600);
 Blynk.begin(auth); 
}

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

for the first test of the fotware blink, I turned on a relay directly from a button set to digital pin

Could be a Arduino Yun and/or networking thing? Perhaps power as when disconnected from the USB it will run off of whatever else you supply, and perhaps that isn’t up to the challenge?

I don’t have a Yun and have no other ideas.

I don’t think it’s a power problem, I’ve been using this hardware for several years but with competing software.
then after this software was updated I had problems connecting to my ISP.
so I decided to change software.
I don’t think power because after Arduino disconnects if I connect the USB cable it doesn’t reconnect, I have to open the serial monitor.
I think more of a bug on the library that runs the W5500 that from what I see in the forum is little used.

Blynk is constantly communicating across the device, unlike some other apps or programs. This will make hardware instabilities stand out quicker.

I ditched mine years ago as even USB link was super stable compared to my Chinese Ethernet adapter… which did work with basic Arduino examples, just not with Blynk’s constantly-in-use link.

The adapters are generally the issue, particularly the Chinese clones. Many using the Arduino original ethernet shields, and even some lucky clones, can run with that library and no issue… others find them unstable if you look at it sideways.

All this means is that you just rebooted the Arduino… that is a normal result when opening the Serial Monitor with an Arduino.

You can search this forum for some possible “After Blynk disconnection, keep code running and attempt reconnection” options that will even work with Arduino with shield (although generally meant for ESP and WiFi)

today the device has remained connected without a USB connection from 11:00 to 18: 40.
I already use an automatic reconnection system:

    void CheckConnection(){  // connection control and general synchronism******
      if(!Blynk.connected())
    {
    Serial.println("Not connected to Blynk server"); 
    connected = 0;
    isFirstConnect = 1;
    Blynk.connect();  // try to connect to server with default timeout
      } 
    else{ connected = 1;
    if ( isFirstConnect ==1) { 
    Blynk.syncAll();
    isFirstConnect = 0;
    Serial.println("Connected to Blynk server");
    }
    }

I formatted your post as (again) it is required for code…

Are you using Blynk.begin() or Blynk.config() ?

http://docs.blynk.cc/#blynk-firmware-configuration

i use Blynk.begin

It is a blocking command, no connection no further processing, so your reconnection routine may not work once you loose connection.

Look at the Blynk.config() option.

I replaced Blynk.begin (auth); with Blynk.config (auth, “blynk-cloud.com”, 8442); but the device has no longer connected.

in the serial monitor I have this:

[5001] Connecting to blynk-cloud.com:8442
[10002] Connecting to blynk-cloud.com:8442
Not connected to Blynk server
[15003] Connecting to blynk-cloud.com:8442
[20004] Connecting to blynk-cloud.com:8442
Not connected to Blynk server
[25005] Connecting to blynk-cloud.com:8442
[30006] Connecting to blynk-cloud.com:8442

As per the docs, you need to establish your own network connection prior to that command. I have long forgotten how that is done with ethernet, but I am sure you can figure it out as it will be the same way as with non-Blynk code.

there are no example programs?

Not in the Sketch Builder. Just connecting to ethernet is not a Blynk specific process.

So aside from the Blynk.Begin() method that does it for you as part of the connection package (using basic DHCP), you can easily search this forum to see if/how others have done it other ways.

I give up understanding what’s wrong, I’m ordering an ESP8266

1 Like

Hopefully something like a NodeMCU or Wemos D1 Mini, so that the Due can go in the bin along with the W5500?

Pete.

Oh… nooo… everyone, please send me all old Arduinos you would otherwise dispose of, I use them for lots of things besides (and including) IoT :stuck_out_tongue: (JK of course, while I would gladly take them, the shipping would make it a invalid proposition :frowning: )

I replaced the w5500 with a w5100, now it’s much more stable and faster but if I reset the system it doesn’t connect by itself.

always needs to start the serial monitor.

image

Pete.

1 Like