witnessmenow / Universal-Arduino-Telegram-Bot

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

SendMessageFromEvent example returns 0 on NodeMcu V3 #237

Closed FelixBurkhard closed 3 years ago

FelixBurkhard commented 3 years ago

Hello everyone,

thanks for this nice library :) I tried to send a message to my telegrambot using the SendMessageFromEvent example. I changed the WiFi SSID and password, and the BotToken and ChatID to the corresponding values from my bot. Unfortunatly, I always get a 0 as return value from bot.sendMessage(CHAT_ID, "Bot started up", ""); I use the NodeMcu V3 ESP8266 board. Has anyone ever experienced a similar problem or has any idea that could help me to solve this? If you need any further information to investigate just let me know.

Thanks in advance. Felix

iurii-untilov commented 3 years ago

Hi @FelixBurkhard , I've experienced the same behavior, because I tried to simplify the example and removed some code. It looks like the code related to time is mandatory for the setup:

  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);
  }

After adding this code into setup() function I was able to send messages. Regards.

FelixBurkhard commented 3 years ago

Hello @iurii-untilov thanks alot for your response. Unfortunatly, adding your code snippet did not change the behaviour. Did you change anything else? Regards, Felix

FelixBurkhard commented 3 years ago

Ok I fixed it. I had a typo in my BotID :no_mouth: Thanks again to @iurii-untilov 👍