Disconnected after RTC sync? Why it doesn't reconnect?

Hello guys, I’m having problem with RTC, I get disconnect from blynk sometimes after RTC sync… Look at the log… Why it doesn’t reconnects? What should I do?

[3888976] <[06|09]j[00|00]
[3889157] >[00|09]j[00|C8]
[3889780] <[14|09]k[00|07]vw[00]10[00]2
[3892310] <[14|09]l[00|0B]vw[00]100[00]3892
[3893840] <[14|09]m[00|07]vw[00]10[00]2
[3896288] <[14|09]n[00|0C]vw[00]14[00]28.416
[3896479] <[14|09]o[00|0C]vw[00]16[00]70.800
[3897356] <[14|09]p[00|0B]vw[00]100[00]3897
[3897884] <[14|09]q[00|07]vw[00]10[00]2
[3901930] <[14|09]r[00|07]vw[00]10[00]2
[3902462] <[14|09]s[00|0B]vw[00]100[00]3902
[3903167] <[06|09]t[00|00]
[3903350] >[00|09]t[00|C8]
[3906287] <[14|09]u[00|0C]vw[00]14[00]28.409
[3906506] <[14|09]v[00|0C]vw[00]16[00]70.700
[3906776] <[14|09]w[00|07]vw[00]10[00]2
[3907511] <[14|09]x[00|0B]vw[00]100[00]3907
[3909994] <[14|09]y[00|07]vw[00]10[00]2
[3912588] <[14|09]z[00|0B]vw[00]100[00]3912
[3914067] <[14|09]{[00|07]vw[00]10[00]2
[3916266] <[14|09]|[00|0C]vw[00]14[00]28.409
[3916449] <[14|09]}[00|0C]vw[00]16[00]70.700
[3917355] <[06|09]~[00|00]
[3917538] >[00|09]~[00|C8]
[3917658] <[14|09|7F|00|0B]vw[00]100[00]3917
[3918080] <[14|09|80|00|07]vw[00]10[00]2
[3922141] <[14|09|81|00|07]vw[00]10[00]2
[3922731] <[14|09|82|00|0B]vw[00]100[00]3922
[3926277] <[14|09|83|00|0C]vw[00]14[00]28.409
[3926460] <[14|09|84|00|0C]vw[00]16[00]70.700
[3926737] <[14|09|85|00|07]vw[00]10[00]2
[3927826] <[14|09|86|00|0B]vw[00]100[00]3927
[3930225] <[14|09|87|00|07]vw[00]10[00]2
[3931540] <[06|09|88|00|00]
[3931730] >[00|09|88|00|C8]
[3932903] <[14|09|89|00|0B]vw[00]100[00]3932
[3934271] <[14|09|8A|00|07]vw[00]10[00]2
[3936317] <[14|09|8B|00|0C]vw[00]14[00]28.409
[3936510] <[14|09|8C|00|0C]vw[00]16[00]70.700
[3936703] <[11|09|8D|00|08]rtc[00]sync

What is your hardware, minimal sketch to reproduce, etc?
How can one help with the limited info you provided? Did you read the “welcome topic”?

I’m using an ESP-8266 + Arduino Mega 2560

void  Horario()
{
  if (timeStatus() > 0) // (RELÓGIO) Se o relógio global via Ethernet sincronizar, então atualizar horário do relógio local DS3231
  {
    if (minute() != myNextion.getComponentValue("menuhome.minvar"))
    {
      myNextion.setComponentValue("menuhome.hrvar", String(clock.dateFormat("H", clock.getDateTime())).toInt()); // (RELÓGIO) Horas
      myNextion.setComponentValue("menuhome.minvar", String(clock.dateFormat("i", clock.getDateTime())).toInt()); // (RELÓGIO) Minutos
      myNextion.setComponentValue("menuhome.segvar", String(clock.dateFormat("s", clock.getDateTime())).toInt()); // (RELÓGIO) Segundos
    }
    if (Sincronizado == false) // (RELÓGIO) Se ainda não foi feita a primeira sincronizacação após o relógio global atualizar, então sincronizar
    {
      clock.setDateTime(year(), month(), day(), hour(), minute(), second()); // (RELÓGIO) Sincronizar horário local com mundial
      setSyncInterval(3600); // (RELÓGIO) Atualiza o relógio global de 1 em 1 hora
      Sincronizado = true;
    }
    if (DiaAtual != (String(clock.dateFormat("d", clock.getDateTime())))) // (ATUALIZAÇÃO) Sincronizar e Atualizar data, mês, ano e etc de dia em dia
    {
      clock.setDateTime(year(), month(), day(), hour(), minute(), second()); // (RELÓGIO) Sincronizar horário local com mundial
      myNextion.setComponentText("menuhome.t9", String(clock.dateFormat("d", clock.getDateTime()))); // (RELÓGIO) Dia
      myNextion.setComponentText("menuhome.t4", String(clock.dateFormat("l", clock.getDateTime()))); // (RELÓGIO) Dia da Semana
      myNextion.setComponentText("menuhome.t12", String(clock.dateFormat("Y", clock.getDateTime()))); // (RELÓGIO) Ano
      myNextion.setComponentText("menuhome.t13", String(clock.dateFormat("F", clock.getDateTime()))); // (RELÓGIO) Mês por extenso
      myNextion.setComponentText("menusensores2.t2", String(clock.dateFormat("t", clock.getDateTime()))); // (RELÓGIO) Dias que tem o mês
      myNextion.setComponentText("menusensores2.t3", String(clock.dateFormat("z", clock.getDateTime()))); // (RELÓGIO) Dias até hoje
      myNextion.setComponentText("menusensores2.t0", String(clock.dateFormat("d/m/y", clock.getDateTime()))); // (RELÓGIO) Data Atual
      DiaAtual = (String(clock.dateFormat("d", clock.getDateTime()))); // (ATUALIZAÇÃO) Quando sincronizar com horário mundial, então começar a sinconizar tudo de dia em dia
    }
  }
}

This’s the part of sync, it happens every 10 seconds (using Timer)

Another error…

[3443038] <[06|09|94|00|00]
[3443238] >[00|09|94|00|C8]
[3446792] <[14|09|95|00|08]vw[00]10[00]73
[3447467] <[14|09|96|00|0C]vw[00]14[00]32.423
[3447659] <[14|09|97|00|0C]vw[00]16[00]63.900
[3447942] <[14|09|98|00|0B]vw[00]100[00]3447
[3450832] <[14|09|99|00|08]vw[00]10[00]73
[3452587] <[14|09|9A|00|0B]vw[00]100[00]3452
[3454876] <[14|09|9B|00|08]vw[00]10[00]73
[3457422] <[06|09|9D|00|00]
[3457587] <[14|09|9C|00|0C]vw[00]14[00]32.441
[3457808] >[00|09|9D|00|C8]
[3457818] <[14|09|9E|00|0C]vw[00]16[00]64.000
[3458084] <[14|09|9F|00|0B]vw[00]100[00]3458
[3468107] Cmd error

Cmd error? What’s that?

Looks like you are just processing too much in that single function, particularly over a ‘ESP as Shield’ connection, which may be a bit flakier than a dedicated ESP MCU… Thus causing Blynk to lose connection when it is unable to maintain its internal housekeeping.

The latest Blynk library 0.5.0 might help a bit… but I first suggest you break all those Nextion display writes down into more manageable sections and send them on separate timers, one after another

Basicly a bad or unrecognisable command… probably due to part of the connection loss.

Gotcha… But most of there commands doesnt need an internet connection…

Not sure what you mean by “there commands”… but it is not specifically an internet thing… more like something is taking to long away from running the Blynk.run(); command n the void loop() so Blynk’s housekeeping doesn’t get done and Blynk loses connection to its server.

They said to me Blynk have a 10 second heart beat time, this function executes in less than a half second… And I still cant figure out why it stops, and doesnt simply disconnect and reconnects…

Well, you know more about whatever your project does than we do.

Honestly, disconnections can happen for many reasons, and while we can guess and make suggestions… that is all they are.

If you can supply more clarity, details, version numbers and properly formatted code… then maybe we can assist further.

I’ll try… I’m using tons of sensors in my Project, temperature sensor, buzzer, nextion display, esp module, and a real time clock…

So, I use the RTC to sync my DS3231, I read a lot about flooding… My sketch is not flooding, and my interval from each Blynk.run() is short, not more than half a second…

I was watching the debug and I saw it normally stops when the arduino tries to sync with RTC (as you can see the debug log above), the problem probably is this, I dont why 90% of syncs its sucessful and only one stops all my arduino…

Why?? A physical RTC module is designed to keep accurate time in the first place, particularly when a device is NOT connected to the internet, where it could otherwise get the correct time… and Blynk’s RTC is meant as such a network connected alternative. So use one or the other, but don’t try to sync one with the other every 10 seconds.

I know, but I am not syncing every 10 seconds, but every 3 hours…

Well… then I don’t have a clue what you are doing or what is wrong, sorry :confused:

I changed it for 10 seconds only for testing, but it was syncing every 3 hours.

Is there any command which I can skip the sync if it takes so long?

Again… why try to “fix” something that shouldn’t need to happen in the first place. Use the Clock Module and have it update your skript every day or so, or use RTC the same way. Just don’t try to use both unnecessarily.

Then, if either ONE of those is the issue, stop using it in this script and move to another smaller example for more thorough tests that we might then be able to assist with.

Ok, I’m gonna do that… But I’ve a problem at the moment… How can I get weekday and month in Blynk RTC? I mean, weekday like “Monday” “Tuesday”… And month like “January”…

That’s one of reasons that I’m using both…

Probably same way as any other Time library… breaking down the UI into specified units and applying “Words” to the numbers… Month 01 = “January”… 12 = “December”, etc.

https://github.com/blynkkk/blynk-library/blob/master/examples/Widgets/RTC/RTC.ino

Yea man, I got it… I’m going to make some changes in my project and follow what you suggested to me…

I’ll post results soon. Should I reply this message or simply edit it?

Thanks a lot.

Reply is best for continuity.

Ok… I’ve news… I changed my code, and removed the DS3231 clock… Now I’m using only the Blynk RTC…

Now it’s like this

void  Horario()
{
  if (timeStatus() > 0) // (RELÓGIO) Se o relógio global via Ethernet sincronizar, então atualizar o horário
  {
    if (minute() != myNextion.getComponentValue("menuhome.minvar"))
    {
      myNextion.setComponentValue("menuhome.hrvar", hour()); // (RELÓGIO) Horas
      myNextion.setComponentValue("menuhome.minvar", minute()); // (RELÓGIO) Minutos
      myNextion.setComponentValue("menuhome.segvar", second()); // (RELÓGIO) Segundos
      //setSyncInterval(3600); // (RELÓGIO) Atualiza o relógio global de 1 em 1 hora
    }
    if (DiaAtual != day()) // (ATUALIZAÇÃO) Sincronizar e Atualizar data, mês, ano e etc de dia em dia
    {
      myNextion.setComponentValue("menuhome.dia", day()); // (RELÓGIO) Dia
      myNextion.setComponentValue("menuhome.diasem", weekday()); // (RELÓGIO) Dia da Semana
      myNextion.setComponentValue("menuhome.mes", month()); // (RELÓGIO) Mês
      myNextion.setComponentValue("menuhome.ano", year()); // (RELÓGIO) Ano
      DiaAtual = day(); // (ATUALIZAÇÃO) Quando sincronizar com horário mundial, então começar a sinconizar tudo de dia em dia
    }
  }
}

But I still have the same problem… When the clock try to sync, all my code stops… Look at the log…

[117868] <[14|00]T[00|08]vw[00]10[00]76
[121306] <[14|00]U[00|0A]vw[00]100[00]121
[121921] <[14|00]V[00|08]vw[00]10[00]76
[124514] <[06|00]W[00|00]
[124690] >[00|00]W[00|C8]
[125444] <[14|00]X[00|0C]vw[00]14[00]30.852
[125670] <[14|00]Y[00|0C]vw[00]16[00]63.400
[125855] <[11|00]Z[00|08]rtc[00]sync