witnessmenow / Universal-Arduino-Telegram-Bot

Use Telegram on your Arduino (ESP8266 or Wifi-101 boards)
MIT License
1.09k stars 302 forks source link

+- 5 sec delay every time my code checks telegram #255

Closed prontodos closed 2 years ago

prontodos commented 2 years ago

I am using D1 mini ESP8266

code snip

void loop() { currentMillis = millis(); checktele(); dosomething(); }

void checktele() { if (currentMillis - previousMillis >= interval) { int numNewMessages = bot.getUpdates(bot.last_message_received + 1); while (numNewMessages) { Serial.println("got response"); handleNewMessages(numNewMessages); numNewMessages = bot.getUpdates(bot.last_message_received + 1);

previousMillis = currentMillis;
}

} }

void dosomething() { Serial.println("dd"); }

Result form the console

17:16:43.710 -> dd 17:16:47.354 -> dd 17:16:50.765 -> dd 17:16:54.210 -> dd 17:16:57.588 -> dd 17:17:01.002 -> dd 17:17:04.413 -> dd 17:17:07.826 -> dd 17:17:11.239 -> dd 17:17:14.651 -> dd 17:17:18.065 -> dd

As you can see from above my dosomething() is looping very slow about 5 seconds.

Why ? Anybody has encountered this ? how to resolve this ?

witnessmenow commented 2 years ago

I responded on the group to this, nearly all your delays are about 3.5 seconds, which is longer than I would expect, but not crazy off. Https requests on Arduino are just slow, I would expect around 2 seconds for an esp8266

Things to try:

prontodos commented 2 years ago

Got it thank you !!