All -
Environment:
Arduino IDE 1.8.3 (Mac iOS)
Arduino MKR1000
Blynk 2.10.1 (Mac iOS)
I have a functional sketch that sends data from various sensors using BlynkTimer. The timer calls 4 separate functions that send data using the Blynk.virtualWrite( ) command. I have all 4 timer intervals set for 15 seconds.
The problem I am having is a dropped connection to the Blynk Cloud. It is not immediate. and not consistent. By reading some of the other posts, I have decided to simplify the sketch to just a basic WiFi example that sends no data and has no timers.
It is the “Arduino_WiFi_Shield_101” sketch. (No changes)
By doing this I can prove to myself that the physical connection is not the problem, but rather there is something in the sketch that is causing either a “flood” issue, or that perhaps because I am not “pushing” data often to keep the connection alive. “Heartbeat” ???
As of this evening, I have had a solid connection for 5 hours. No data of course, but just an “Online” status.
As I understand it, Blynk sends a ping every 8 seconds just to tell the server that everything is OK. If it does not receive a ping, it tries to reconnect because of the simple structure in the loop( ) section of the sketch
// Begin the loop section
void loop()
{
Blynk.run();
timer.run();
}
The specific questions are:
Is there a recommended protocol or “common practice” in how I set up my timer intervals so that I send the data as Blynk is expecting to receive it? All of the test examples seem to be set for 1000 millis.
Should I NOT have the same interval for the four timer functions so that they do not “stack” on top of each other. My understanding is that they process in the order in which they are called … some process perhaps slower than others.
Lastly … just for clarity … what is the significance of the “L” in the timer.Interval function? “timer.setInterval(15000L, flowSensorData);”
I have never used the “log” to monitor the interaction with the server, and I am not sure how to interpret the data even if I knew how to set it up … perhaps that is for another day.
Thanks for all the help in the past … and I appreciate the wonderful support by the community and techs.
Jim