It is very strange, I live in place where neighbors is 300m away, so there is clear from any signals and this board I test near the router, there can’t be week signal. I also was try both, external power supply and power supply from USB (same lost connection). I have two WeMos boards, I have tested both - the same. If I use this simple connection see test then board longest connection time is 15sec usualy it is 2-3 sec. If I load more complicated code, then it was reconnecting every single read (read set to 1sec).
As there can see connection is not lost until I turn on my phone and start to read value evey one second.
[10317] Connected to WiFi
[10317] IP: 192.168.1.113
[10317] Blynk v0.4.0 on Arduino
[10317] Connecting to blynk-cloud.com:8442
[10438] Ready (ping: 1ms).
[127349] Login timeout
[127350] Connecting to blynk-cloud.com:8442
[127448] Ready (ping: 1ms).
[133665] Login timeout
[133668] Connecting to blynk-cloud.com:8442
[133765] Ready (ping: 2ms).
[139703] Login timeout
[139706] Connecting to blynk-cloud.com:8442
[139806] Ready (ping: 2ms).
[146633] Login timeout
[146634] Connecting to blynk-cloud.com:8442
[146736] Ready (ping: 3ms).
[153730] Login timeout
[153730] Connecting to blynk-cloud.com:8442
[153830] Ready (ping: 0ms).
[159778] Login timeout
[159780] Connecting to blynk-cloud.com:8442
[159890] Ready (ping: 0ms).
[166734] Login timeout
[166735] Connecting to blynk-cloud.com:8442
[166835] Ready (ping: 1ms).
[172700] Login timeout
[172702] Connecting to blynk-cloud.com:8442
[172803] Ready (ping: 1ms).
[180763] Login timeout
[180766] Connecting to blynk-cloud.com:8442
[180894] Ready (ping: 1ms).
[186811] Login timeout
[186813] Connecting to blynk-cloud.com:8442
[186917] Ready (ping: 0ms).
[192736] Login timeout
[192738] Connecting to blynk-cloud.com:8442
[192839] Ready (ping: 2ms).
More complicated is looks like this:
In first tab is my room light control, and in this what you see is is my pellet burner control in stove. It is read data from arduino what control stove. Its send room temperature, stove temperature, fire sensor 1 and 2 in % and others…
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "db39dc4630404f06afcaa25cac1f61b8";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "TP-LINK_HOME";
char pass[] = "samtenes";
int var;
int count;
int x;
int c;
//Variables for Serial receive<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
bool start = false;
bool end = false;
int inData[27]; // Leave plenty of room
char inDataChar[27]; // Leave plenty of room
byte index1;
byte SerialMem;
String inString_1;
String inString_2;
String inString_3;
String inString_4;
String inString_5;
String inString_6;
String inString_7;
String inString_8;
String inString_9;
String inString_10;
//Variables
int Room_t;
int Stove_t;
int Fire_1;
int Fire_2;
int Mode;
int AutoManual;
int Auger;
int Starter;
int Vent;
int value_x;
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
int temp;
int temp2;
SimpleTimer timer;
WidgetLED led7(V7);
WidgetLED led8(V8);
WidgetLED led9(V9);
WidgetLED led10(V10);
WidgetLED led11(V11);
void setup()
{
// Wire.begin();
Serial.begin(115200);
// Blynk.begin(auth, ssid, pass);
// Or specify server using one of those commands:
//Blynk.begin(auth, ssid, pass, "server.org", 8442);
Blynk.begin(auth, ssid, pass);
timer.setInterval(1500L, myTimerEvent);
//timer.setInterval(2000L, myTimerEvent2);
}
BLYNK_READ(V1)
{
// STATUS SEND SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
count = count +1;
if (count > 5)
count = 0;
// Usually, you will need to respond with a virtual pin value.
if (count == 0)
Blynk.virtualWrite(1, "< ");
if (count == 1)
Blynk.virtualWrite(1, " ( ");
if (count == 2)
Blynk.virtualWrite(1, " )");
if (count == 3)
Blynk.virtualWrite(1, " >");
if (count == 4)
Blynk.virtualWrite(1, " )");
if (count == 5)
Blynk.virtualWrite(1, " ( ");
// STATUS SEND SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
}
void myTimerEvent()
{
SerialReceive(); //there is reading Serial info at speed 115200 from another arduino
}
void myTimerEvent2()
{
//led ###########################################
if (AutoManual == 1) //0 = manual / 1 = AUTO
{
led8.off();
led7.on();
}
else
{
led8.on();
led7.off();
}
if (Auger == 1) //Auger
led9.on();
else
led9.off();
if (Starter == 1) //starter - 1=on
led10.on();
else
led10.off();
if (Vent == 1) //vent - 1=on
led11.on();
else
led11.off();
}
BLYNK_WRITE(12)
{
BLYNK_LOG("Got a value: %s", param.asInt());
if(param.asInt() == 1)
Serial.print("<F>");
}
BLYNK_WRITE(13)
{
BLYNK_LOG("Got a value: %s", param.asInt());
if(param.asInt() == 1)
Serial.print("<B>");
}
BLYNK_WRITE(14)
{
BLYNK_LOG("Got a value: %s", param.asInt());
if(param.asInt() == 1)
Serial.print("<C>");
}
BLYNK_WRITE(15)
{
BLYNK_LOG("Got a value: %s", param.asInt());
if(param.asInt() == 1)
Serial.print("<D>");
else
Serial.print("<d>");
}
BLYNK_WRITE(16)
{
BLYNK_LOG("Got a value: %s", param.asInt());
Serial.print("<E>");
}
BLYNK_WRITE(17)
{
BLYNK_LOG("Got a value: %s", param.asInt());
if(param.asInt() == 1)
Serial.print("<A>");
}
BLYNK_READ(V2)
{
String str;
char result[5];
result[0]=(Room_t/100)+'0';
result[1]=((Room_t/10)%10)+'0';
result[2]='.';
result[3]=(Room_t%10)+'0';
result[4]='\0';
str +=result;
str +="℃";
//char buf[str.length()+1];
char buf[8];
str.toCharArray(buf,sizeof(buf));
Blynk.virtualWrite(2,buf);
}
BLYNK_READ(V3)
{
String str2;
//char result2[4];
//result2[0]=(temp2/100)+'0';
//result2[1]=((temp2/10)%10)+'0';
//result2[2]=(temp2%10)+'0';
//result2[3]='\0';
str2 +=Stove_t;
str2 +="℃";
//char buf[str.length()+1];
char buf2[8];
str2.toCharArray(buf2,sizeof(buf2));
Blynk.virtualWrite(3,buf2);
}
BLYNK_READ(V4)
{
Blynk.virtualWrite(4,Fire_1);
}
BLYNK_READ(V5)
{
Blynk.virtualWrite(5,Fire_2);
}
BLYNK_READ(V6)
{
if (Mode == 0) // mode 0 = 90>.. / 1 = STOP / 2 = keep t
{
Blynk.virtualWrite(6,"90>..");
}
if (Mode == 1)
{
Blynk.virtualWrite(6,"ASTOP");
}
if (Mode == 2)
{
Blynk.virtualWrite(6,"KEEPT");
}
}
void loop()
{
Blynk.run();
}
There is what is in Serial read:
void SerialReceive ()
{
while (Serial.available() > 0 && SerialMem == 0) //SerialMem - read only then is already done something with received data or it is first time to read.
{
int aChar = Serial.read();
if (aChar == '<') // Start of packet marker read
{
index1 = 0;
start = true;
end = false;
}
else if (aChar == '>') // End of packet marker read
{
end = true;
break; // Done reading serial data for now
}
else
{
if (index1 < 27) // Make sure there is room
{
inData[index1] = aChar; // Add char to array
index1++;
}
}
}
// When we get here, there is no more serial data to read,
// or we have read an end-of-packet marker
if (start && end)
{
SerialMem = 1;
// We've seen both markers - do something with the data here
//Print all data array
for (int index1 = 0; index1 < 25; index1++) //for (int index1 = 0; index1 < 7; index1++)
{
inDataChar[index1] = inData[index1]; //convert from int to char, for example int 49 = char 1
Serial.write(inDataChar[index1]);
}
inString_1 = ""; //Reset string
for (int index1 = 0; index1 < 3; index1++)
{
if (isDigit(inData[index1]))
inString_1 += inDataChar[index1]; //add 3 first incoming data to string
else Serial.println("Data received incorectly,data 1 is NOT DIGIT");
}
inString_2 = ""; //Reset string
for (int index1 = 4; index1 < 7; index1++)
{
if (isDigit(inData[index1]))
inString_2 += inDataChar[index1]; //add 3 second incoming data to string
else Serial.println("Data received incorectly,data 2 is NOT DIGIT");
}
inString_3 = ""; //Reset string
for (int index1 = 8; index1 < 11; index1++)
{
if (isDigit(inData[index1]))
inString_3 += inDataChar[index1]; //add 3 third incoming data to string
else Serial.println("Data received incorectly,data 3 is NOT DIGIT");
}
inString_4 = ""; //Reset string
for (int index1 = 12; index1 < 15; index1++)
{
if (isDigit(inData[index1]))
inString_4 += inDataChar[index1]; //add 3 fourth incoming data to string
else Serial.println("Data received incorectly,data 4 is NOT DIGIT");
}
inString_5 = ""; //Reset string
inString_6 = ""; //Reset string
inString_7 = ""; //Reset string
inString_8 = ""; //Reset string
inString_9 = ""; //Reset string
inString_10 = ""; //Reset string
if (inData[3] == ',') // Check if 4 data is "," and only then asign string to Value(int)
{
Room_t = inString_1.toInt(); //Seperated values_1
Stove_t = inString_2.toInt(); //Seperated values_2
Fire_1 = inString_3.toInt(); //Seperated values_3
Fire_2 = inString_4.toInt(); //Seperated values_4
if (isDigit(inData[16]))
{
inString_5 += inDataChar[16]; //char to string to int
Mode = inString_5.toInt();
}
else Serial.println("Data received incorectly,data 16 is NOT DIGIT");
if (isDigit(inData[18]))
{
inString_6 += inDataChar[18]; //char to string to int
AutoManual = inString_6.toInt();
}
else Serial.println("Data received incorectly,data 18 is NOT DIGIT");
if (isDigit(inData[20]))
{
inString_7 += inDataChar[20]; //char to string to int
Auger = inString_7.toInt();
}
else Serial.println("Data received incorectly,data 20 is NOT DIGIT");
if (isDigit(inData[22]))
{
inString_8 += inDataChar[22]; //char to string to int
Starter = inString_8.toInt();
}
else Serial.println("Data received incorectly,data 22 is NOT DIGIT");
if (isDigit(inData[24]))
{
inString_9 += inDataChar[24]; //char to string to int
Vent = inString_9.toInt();
}
else Serial.println("Data received incorectly,data 24 is NOT DIGIT");
if (isDigit(inData[26]))
{
inString_10 += inDataChar[26]; //char to string to int
value_x = inString_10.toInt();
}
else Serial.println("Data received incorectly,data 26 is NOT DIGIT");
} else Serial.println("Data received incorectly, WITHOUT , SEPERATOR");
/*
Serial.print(" ");
Serial.print(Room_t);
Serial.print(" ");
Serial.print(Stove_t);
Serial.print(" ");
Serial.print(Fire_1);
Serial.print(" ");
Serial.print(Fire_2);
Serial.print(" ");
Serial.print(Mode);
Serial.print(" ");
Serial.print(AutoManual);
Serial.print(" ");
Serial.print(Auger);
Serial.print(" ");
Serial.print(Starter);
Serial.print(" ");
Serial.print(Vent);
Serial.print(" ");
Serial.print(value_x);
*/
Serial.println();
start = false;
end = false;
SerialMem = 0;
}
}
I have previously run this example on my expensive Arduino WiFi module for an year it was working perfectly, but after update to blynk version 0.4.0 I can’t get connection with internet with this module (May be you can help me there too). It is why I buy WeMos D1 to test how it works with blynk, (I planing to use it in future to automatize all) because it is more times cheaper too. But now too no luck 