I’ve already looked inside the BlynkConfig.h file and did not see an option to look like something about increasing the communication time between the Arduino and the Blynk server.
Or maybe it’s something else. is what is the fact that the code pinging a local IP does this make the Arduino disconnect from the Blynk server?
Unfortunately you missed looking into the Welcome Topic… Can you do so, then edit your post with properly formatted code,
Then spend some time reading the Documentation and Help Center files to see why using a 7 second delay is a bad thing to do (even more use of differing timers can eliminate such need). There could be more issues as well, but I gave up reading through the unformatted code
Any delay or loop that exceeds Blynk’s heartbeat timeout will cause disconnection. You can try to code around it with checks and reconnection code, but it basically comes down to proper time management.
Is not that a way to increase Blynk’s time a little?
Thanks for the links, I had already visited all of them, but I did not get answers.
As for good time management, the rest of my code uses the recommended timers to do the sensor readings, on average it sends the information to the APP every 10 seconds. Not overloading the same way.
Only the ping that varies between 2ms to 4ms, this has no way of decreasing the time.
I wanted to know if there is any way to increase the time that blynk.run () connects to the server, so it does not see those small millisecond delays.
your disconnections for sure not caused by those 2 or 4 millisecond delays. the blynk system can easily handle even several 100 millisecond delays, up to 500 or so.
i feel the problem is somehow related to the ethernet library or some other protocol… probably somehow when you init the ping, it gets disconnected from the blynk server.
i would try the following experiments:
even if the ping is only 4 ms, but maybe the WHOLE PINGING PROCEDURE takes much more time, and this causes the disconnections. for example, if i do a ping on my pc from a terminal, i can have 4 ms ping, but the time to execute the whole command takes some seconds. to measure the actual time, put a serial.println(millis()) before and after the pinging function, and see what it gets. if that is more than 500 ms, than there is the cause.
try the same code (with the neccessary modifications of course) on a esp8266 board (with the 2.4.0-rc2 esp core). and see if the disconnection occures. if not, than probably the cause is related to the ethernet library internal protocols
Shows intervals between 2ms and 4ms. So I guess it’s not a matter of time. It must be internal ethernet library protocols. Which should be much harder to solve.
Nobody responded to that issue, but they can be like that over on the Arduino forum
You might be better looking for a different solution, or raising the issue with the author of the ICMPing library.
In the BlynkConfig.h file in the “\ libraries \ Blynk \ src \ Blynk” folder, you have the following options.
#ifndef BlynkConfig_h
#define BlynkConfig_h
#include <Blynk/BlynkDetectDevice.h>
/***************************************************
* Change these settings to match your need
***************************************************/
#define BLYNK_DEFAULT_DOMAIN "blynk-cloud.com"
#define BLYNK_DEFAULT_PORT 8442
#define BLYNK_DEFAULT_PORT_SSL 8441
/***************************************************
* Professional settings
***************************************************/
// Library version.
#define BLYNK_VERSION "0.5.0"
// Heartbeat period in seconds.
#ifndef BLYNK_HEARTBEAT
#define BLYNK_HEARTBEAT 10
#endif
// Network timeout in milliseconds.
#ifndef BLYNK_TIMEOUT_MS
#define BLYNK_TIMEOUT_MS 2000UL
#endif
// Limit the amount of outgoing commands per second.
#ifndef BLYNK_MSG_LIMIT
#define BLYNK_MSG_LIMIT 15
#endif
// Limit the incoming command length.
#ifndef BLYNK_MAX_READBYTES
#define BLYNK_MAX_READBYTES 256
#endif
// Limit the outgoing command length.
#ifndef BLYNK_MAX_SENDBYTES
#define BLYNK_MAX_SENDBYTES 128
#endif
// Uncomment to disable built-in analog and digital operations.
//#define BLYNK_NO_BUILTIN
// Uncomment to disable providing info about device to the server.
//#define BLYNK_NO_INFO
// Uncomment to enable debug prints.
//#define BLYNK_DEBUG
// Uncomment to force-enable 128 virtual pins
//#define BLYNK_USE_128_VPINS
// Uncomment to disable fancy logo
//#define BLYNK_NO_FANCY_LOGO
// Uncomment to enable 3D fancy logo
//#define BLYNK_FANCY_LOGO_3D
// Uncomment to enable experimental functions.
//#define BLYNK_EXPERIMENTAL
// Uncomment to disable all float/double usage
//#define BLYNK_NO_FLOAT
// Uncomment to switch to direct-connect mode
//#define BLYNK_USE_DIRECT_CONNECT
// Uncomment to append command body to header (uses more RAM)
//#define BLYNK_SEND_ATOMIC
// Split whole command into chunks (in bytes)
//#define BLYNK_SEND_CHUNK 64
// Wait after sending each chunk (in milliseconds)
//#define BLYNK_SEND_THROTTLE 10
#endif
I don’t think so. Basically that’s some conflict of the Ping library which apparently kills existing connections, including Blynk connection to the cloud.
I guess I didn’t pay enough attention… here I was thinking of what I call a PING sensor, AKA ultrasonic sensor… not a library for pinging network connections
Yes, such a thing would override any other network connections while running… otherwise it would not be getting accurate readings… kinda like determining how loud a fan is… in a hurricane Which does raise the feasibility of using IoT software for testing Network conditions, due to the contradictory networking needs of each.
@chacalgbi It might be doable, but you would first need to run something like Blynk.disconnect() run your Network PING scan, store the results, restart Blynk’s connection with Blynk.connect() then send those results through to the App for display.
Buddy, your idea of using Blynk.disconnect () and Blynk.connect () worked, the application continues to connect and disconnect, but it is very fast.
Thank you very much!! I’m going to ping and connect and disconnect on the Blynk server once a minute. Is that a problem? Can the Blynk server permanently disconnect me for this?
follow the code below:
void pingar(){ // once per minute
if (habilita_ping1 == 1)
{
Blynk.disconnect();
ICMPEchoReply echoReply = ping1(pingAddr1, 4);
if (echoReply.status == SUCCESS){conta_ping1=0;}
else{conta_ping1++;}
if(conta_ping1 >= 2)
{
digitalWrite(saida1,HIGH); ultimo_tempo = millis();
}
Blynk.connect();
}
}
this system will check if some devices that are in a remote place are working, in case they stop responding, I will restart their energy for 10 seconds.