Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieving time #337

Open
ehraz786 opened this issue Sep 24, 2023 · 4 comments
Open

Retrieving time #337

ehraz786 opened this issue Sep 24, 2023 · 4 comments

Comments

@ehraz786
Copy link

ehraz786 commented Sep 24, 2023

is retrieving time from ntp necessary?
without "time_t now" the bot doesn't receive any message.

Serial.print("Retrieving time: ");
configTime(0, 0, "pool.ntp.org");
time_t now = time(nullptr);
while (now < 24 * 3600)
{
  Serial.print(".");
  delay(100);
  now = time(nullptr);
}
Serial.println(now);
@Hegy
Copy link

Hegy commented Sep 29, 2023

Hello!
Please try to connect to another wifi device (router or hot-spot on your mobile).

@ehraz786
Copy link
Author

Tried it.
Without retrieving the time, the bot fails to receive any message.

@Hegy
Copy link

Hegy commented Sep 29, 2023

Is your bot able to send a message without retrieving the time?

@ehraz786
Copy link
Author

ehraz786 commented Sep 30, 2023

I am using the example sketch SendMessageFromEvent.ino from examples/ESP8266/SendMessageFromEvent

bot.sendMessage(CHAT_ID, "Bot started up", "");

This above line works well if the below lines are there

Serial.print("Retrieving time: ");
 configTime(0, 0, "pool.ntp.org"); // get UTC time via NTP
 time_t now = time(nullptr);
 while (now < 24 * 3600)
 {
   Serial.print(".");
   delay(100);
   now = time(nullptr);
 }
 Serial.println(now);

but fails to do anything upon removing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants