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);
}
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)
So I donāt see any reason it canāt work, except the port you are using. For āblynk-cloud.comā it is port 80 now.
Canāt you just leave defaults by using Blynk.config(auth)?
EDIT:
OK, not the only one:
if (!Ethernet.begin(SelectMacAddress(auth, mac))) {
BLYNK_FATAL(BLYNK_F("DHCP Failed!"));
}
The Ethernet.begin(..) but it seems it requires correct arguments. I suppose this entry just initialises network connection, and you may look at some non Blynk related connection example for your connection method. Currently Iām away and canāt look at any code.
You are comparing two disimular commands. There is no āone or otherā, they do different things.
Blynk.config() is just that, it sets up your required configuration like AUTH, Server, Portā¦etc. It is only used once in your setup()
Blynk.connect() does just what it says and trys to take your configured sketch and connect itā¦ this command can be ran whenever needed in your sketchā¦ for example as part of a ākeep running when no internet available, but reconnect when ableā routine.
@Gunner, look at his code. There is nothing wrong with commandās understanding (I think). Itās just the network connection initialization, that is missing here
This Is understand. I indeed want to use Blynk.connect for a āreconnectionā routine.
I think the problem is with the network init which I did not realize was necessary with Blynk.config and Blynk.connect. (from there my comment about a more detailed doc but it might be obvious for better programmers than me )
Iām just guessing, but I stand for āless than optimal wayā the connection is handled by Blynk.begin(). Do You remember the not that old @Nixon 's issue? Iām left with his modifications and Iām quite happy with that