I know there are many posts about this. I think I have read most (all?) of them. However still confused.
I use unixtime to time the Blynk connection (in the Setup function).
//Blynk////////////////////////////// using config
blynkstart=rtc.getUnixTime(rtc.getTime());
Serial.println(rtc.getUnixTime(rtc.getTime()) );// I use Unix time to time the Blynk connection
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
if (digitalRead(A9) == HIGH) {//switch to chose whether or not to try connecting
Blynk.begin(auth, "blynk-cloud.com", 8442);
// Blynk.config(auth, "blynk-cloud.com", 8442);
// Blynk.connect();
Serial.println("Blynk End");Serial.println(rtc.getUnixTime(rtc.getTime()) );Serial.println(rtc.getUnixTime(rtc.getTime())-blynkstart);
}
It generally connects between the 14 and 35 seconds.
However if I use Blynk.connect() instead of Blynk.config() it will never connect:
//Blynk////////////////////////////// using connect
blynkstart=rtc.getUnixTime(rtc.getTime());
Serial.println(rtc.getUnixTime(rtc.getTime()) );// I use Unix time to time the Blynk connection
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
if (digitalRead(A9) == HIGH) {//switch to chose whether or not to try connecting
// Blynk.begin(auth, "blynk-cloud.com", 8442);
Blynk.config(auth, "blynk-cloud.com", 8442);
Blynk.connect();
Serial.println("Blynk End");Serial.println(rtc.getUnixTime(rtc.getTime()) );Serial.println(rtc.getUnixTime(rtc.getTime())-blynkstart);
}
The serial monitor will show several attempt to connect but it will fail to do so:
Connecting to blynk-cloud.com:8442
Connecting to blynk-cloud.com:8442
ā¦
I understand defaut timeout for connect is 30 sec but I have tried several value for Blynk.connect(t). t up to1800000. Always with the same result just more failed attempts to connect.
(Indeed with t at 180000 it times out after 180 sec)
(Arduino Mega 2560 with ethernet card W5100)