Oh, thank you. I will try.
By the way, 0.6.1 contains the old Time library (0.5). But actual 0.6
Can you elaborate on this?
Pete.
0.6.1 work also (((
10:04:22.116 -> [8481] Connected to WiFi
10:04:22.116 -> [8481] IP: 172.18.*.27
10:04:22.116 -> [8481]
10:04:22.116 -> ___ __ __
10:04:22.116 -> / _ )/ /_ _____ / /__
10:04:22.116 -> / _ / / // / _ \/ '_/
10:04:22.116 -> /____/_/\_, /_//_/_/\_\
10:04:22.116 -> /___/ v0.6.1 on ESP8266
10:04:22.116 ->
10:04:22.116 -> [8487] [BlynkArduinoClient] Connecting to 172.18.*.111
10:04:27.134 -> [13488] [BlynkArduinoClient] Connecting to 172.18.*.111
10:04:27.773 -> [14126] Ready (ping: 16ms).
10:04:27.893 -> Blynk Started OK...
10:04:27.893 -> OTA Started OK...
10:04:27.933 -> [14290] Time sync: OK
10:04:36.103 -> Sleeping 30 sec...
10:05:04.205 -> 9:4:37 Wake up!
10:05:33.634 -> WiFi reconnecting...
10:05:33.634 -> [52750] [BlynkSimpleEsp8266] Connecting to ******
10:05:41.113 -> [60225] Connected to WiFi
10:05:41.113 -> [60225] IP: 172.18.*.27
10:05:41.113 -> [60225]
10:05:41.113 -> ___ __ __
10:05:41.113 -> / _ )/ /_ _____ / /__
10:05:41.113 -> / _ / / // / _ \/ '_/
10:05:41.113 -> /____/_/\_, /_//_/_/\_\
10:05:41.113 -> /___/ v0.6.1 on ESP8266
10:05:41.159 ->
10:05:41.159 -> [60231] [BlynkArduinoClient] Connecting to 172.18.*.111
10:05:46.125 -> [65232] [BlynkArduinoClient] Connecting to 172.18.*.111
10:05:51.124 -> [70233] [BlynkArduinoClient] Connecting to 172.18.*.111
10:05:56.134 -> [75234] [BlynkArduinoClient] Connecting to 172.18.*.111
10:05:56.258 -> [75374] Ready (ping: 10ms).
10:05:56.413 -> Connection restored OK...
10:05:56.413 -> Data sending started...
10:05:56.413 -> [75514] Time sync: OK
10:05:59.733 -> Data Sended OK...
10:06:04.744 -> Sleeping 30 sec...
problem solved.
before asleep I do
Blynk.disconnect();
WiFi.mode(WIFI_OFF);
ESP_sleep(30000);
after sleep I do not check the connection
if (!Blynk.connected()) Blynk.connect(25000);
but immediately do the
Blynk.begin(auth, ssid, pass, IPAddress(172,18,1,111), 8080);
In general, after long testing, I found out that after waking up from sleep, the connection to the access point can take up to 30 seconds or more. sometimes frozen.
I modified the library so that it was possible to limit the time of attempts to establish a connection and their number, in order to be able to somehow fork the connection script.
Add 2 functions to BlynkSimpleEsp8266.h
bool connectWiFi_t(const char* ssid, const char* pass, uint16_t timeout = 10000)
{
BLYNK_LOG2(BLYNK_F("Connecting to "), ssid);
WiFi.mode(WIFI_STA);
if (WiFi.status() != WL_CONNECTED) {
if (pass && strlen(pass)) {
WiFi.begin(ssid, pass);
} else {
WiFi.begin(ssid);
}
}
int WFB = timeout / 500; // set default 20 cycles
while ((WiFi.status() != WL_CONNECTED) && (WFB>0)) {
BlynkDelay(500);
--WFB;
}
if (WiFi.status() != WL_CONNECTED) return false;
BLYNK_LOG1(BLYNK_F("Connected to WiFi"));
IPAddress myip = WiFi.localIP();
BLYNK_LOG_IP("IP: ", myip);
return true;
}
bool begin_t(const char* auth,
const char* ssid,
const char* pass,
IPAddress ip,
uint16_t port = BLYNK_DEFAULT_PORT,
uint16_t wifi_timeout = 30000)
{
if (WiFi.status() != WL_CONNECTED) {
uint16_t connect_count = wifi_timeout / 10000;
while ((connectWiFi_t(ssid, pass, wifi_timeout / 3)) && (connect_count>0)) --connect_count;
if (WiFi.status() != WL_CONNECTED) return false;
}
config(auth, ip, port);
return this->connect();
}
Usage example
int conB_count = 5;
while ((!Blynk.begin_t(auth, ssid, pass, IPAddress(172,18,0,100), 8080, 30000)) && (conB_count>0)) --conB_count;
if (WiFi.status() != WL_CONNECTED) ESP.restart();