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?
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)
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.
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…
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.
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”…
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.
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…