witnessmenow / Universal-Arduino-Telegram-Bot

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

The Bot doesn't receives anything #104

Open DaveCalaway opened 5 years ago

DaveCalaway commented 5 years ago

Hi every body, I have decide to use again the "ledbot" i edited one years ago over my esp8266. I loaded the sketch, crated a new bot with bot father, and added in to the sketch the token and the WiFi info. Over the serial, the esp8266, is connected.

Now, when I try to talk with the bot, over the chat, on the /start command, nothing happens.

I download again the library, opened a new bot, but nothing change. I have use 3 different esp8266, other examples in the library example, but still at the same point.

Am I the only one with this problem?

witnessmenow commented 5 years ago

Try changing your esp8266 core to 2.4

Tool->board->board manager

Search for esp8266 and select 2.4 from the drop down and click save/update

On Sun, 13 Jan 2019, 11:14 Dave <notifications@github.com wrote:

Hi every body, I have decide to use again the "ledbot" i edited one years ago over my esp8266. I loaded the sketch, crated a new bot with bot father, and added in to the sketch the token and the WiFi info. Over the serial, the esp8266, is connected.

Now, when I try to talk with the bot, over the chat, on the /start command, nothing happens.

I download again the library, opened a new bot, but nothing change. I have use 3 different esp8266, other examples in the library example, but still at the same point.

Am I the only one with this problem?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot/issues/104, or mute the thread https://github.com/notifications/unsubscribe-auth/ABfXwt_2Xa4kTZ70qCMZ5sIc3z_PQmydks5vCxT9gaJpZM4Z9HU6 .

mnemocron commented 5 years ago

I just had the same issue with any Telegram Bot library that I tried on my NodeMCU. I downgraded the ESP Core to 2.4.2 - now it works! Yesterday I had a similar issue with the ArduinoJson Library on the beta channel. This "upgrade libraries" feature in Arduino is somewhat misleading.

DaveCalaway commented 5 years ago

Right, the last esp8266 Arduino Core is 2.5.0beta2 .
The last stable is the 2.4.2.
Some for the last version of the Json Arduino, the last rev is a beta, don't use the Beta but the Stable.

@witnessmenow could you update the guide in the front page?

edugargon commented 5 years ago

thank you! all works fine with 2.4.2

MrTilllus commented 5 years ago

can you maybe upload your sketch because when i try to connect with my sketch from 2.5 to my wifi with core 2.4.2 it does not

witnessmenow commented 5 years ago

On 2.5 add client.setInsecure(); to the setup of the sketch

On Sun, 10 Mar 2019, 18:09 MrTilllus, notifications@github.com wrote:

can you maybe upload your sketch because when i try to connect with my sketch from 2.5 to my wifi with core 2.4.2 it does not

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot/issues/104#issuecomment-471329449, or mute the thread https://github.com/notifications/unsubscribe-auth/ABfXwvj1lWPoaBYA5yEV6Oe0K5DVhpy9ks5vVUpIgaJpZM4Z9HU6 .

mrsufgi commented 5 years ago

@witnessmenow perhaps we need to add this the the docs.

had the same issues (with ALL telegram bots 🗡 ), downgrading to 2.4.2 works great!

juanmcasillas commented 5 years ago

Hello.

I have the following configuration:

esp8266 by ESP8266 version 2.5.0 I can't connect with api.telegram.org. I set the debug to true, and the problem was in the connection.

new core uses BEARSSL instead axTLS so the semantic changes a little bit. You need to accept all the connections in SSL, without validating the cert. So you only have to put this:

client.setInsecure();

My setup:

  bot._debug = true;
  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was Previously
  // connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  // Attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  client.setInsecure();
}

Hope it helps. Kind Regards,

TheUserDead commented 5 years ago

And if you get nothing when try these advices, check webhook is disabled for your bot. I got angry with myself when I realized this

sindar225 commented 4 years ago

I'm using platformio IDE and trying to make it working on Wemos D1 mini and none of the proposed solutions did work for me. I tried to set client.setInsecure(), use core 2.4.2 or switch to WiFiClientSecureAxTLS - no luck. But what did work for me is changing server's IP in UniversalTelegramBot.h. I just some lines of code from https://github.com/fedrux/ESP8266-TelegramBot and it did the trick. Here's my setup:

platformio.ini

[env:d1_mini]
platform = espressif8266
board = d1
framework = arduino
upload_port = /dev/cu.wchusbserial1420

lib_deps =
   # Using a library name
   ESP8266-TelegramBot=https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot.git#V1.2.0

UniversalTelegramBot.h

#define HOST "149.154.167.198"
#define SSL_PORT 443
#define HANDLE_MESSAGES 1

//unmark following line to enable debug mode
#define _debug

typedef bool (*MoreDataAvailable)();
typedef byte (*GetNextByte)();
typedef byte* (*GetNextBuffer)();
typedef int (GetNextBufferLen)();

const char* fingerprint = "37:21:36:77:50:57:F3:C9:28:D0:F7:FA:4C:05:35:7F:60:C1:20:44";  //Telegram.org Certificate 
javierferwolf commented 4 years ago

hi @sindar225 I have the same problem, I have tried several things without result, I use core 2.4.2 . could you please explain in more detail what steps you followed, because I've done what you've described but it doesn't work. or could you please send me the .h .cpp files? because something i'm not doing right! thank you

witnessmenow commented 4 years ago

Core 2.4 does not work anymore, telegram require a TLS level core 2.4 doesn't support.

Upgrade to 2.5 or higher and add "client.setInsecure();" anywhere in the setup of your sketch

On Sun, 1 Mar 2020, 20:20 javierferwolf, notifications@github.com wrote:

hi @sindar225 https://github.com/sindar225 I have the same problem, I have tried several things without result, I use core 2.4.2 . could you please explain in more detail what steps you followed, because I've done what you've described but it doesn't work. or could you please send me the .h .cpp files? because something i'm not doing right! thank you

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot/issues/104?email_source=notifications&email_token=AAL5PQUMRTQ74M4RB73QUR3RFK7SNA5CNFSM4GPUOU5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENNJWJQ#issuecomment-593140518, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL5PQRCQZCKCB7VUP2D24TRFK7SNANCNFSM4GPUOU5A .

haorfani commented 4 years ago

Hi,

In the following sketch I am trying to send a telegram message through the bot every 5 seconds and it doesn't work. I am able to connect to wifi but I am not able to send messages to telegram successfully. I followed all the instructions to set up the bot and got the token and chatid. What am I am missing here?


 *  Push Notificaiton Demo                                         *
 *  Using IFTTT and Telegram to send alerts to your phone          *
 *                                                                 *
 *  Telegram Library:                                              *
 *  https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot *
 *                                                                 *
 *  IFTTT Maker Library:                                           *
 *  https://github.com/witnessmenow/arduino-ifttt-maker            *
 *                                                                 *
 *  By Brian Lough                                                 *
 *******************************************************************/

//Including the two libraries
#include <UniversalTelegramBot.h>

#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>

//------- WiFi Settings -------
char ssid[] = "XXXXXXXXX";       // your network SSID (name)
char password[] = "YYYYYYY";  // your network key

// ------- Telegram config --------
#define BOT_TOKEN "966974293:AAEU7UOno-Cn1bwA9t276PwYFaLfyir8oeY"  // your Bot Token (Get from Botfather)
#define CHAT_ID "-1094994126" // Chat ID of where you want the message to go (You can use MyIdBot to get the chat ID)

// SSL client needed for both libraries
WiFiClientSecure client;

UniversalTelegramBot bot(BOT_TOKEN, client);

String ipAddress = "";

volatile bool telegramButtonPressedFlag = false;
volatile bool iftttButtonPressedFlag = false;

void setup() {

  Serial.begin(115200);

  client.setInsecure();

  // Set WiFi to station mode and disconnect from an AP if it was Previously
  // connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  // Attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  IPAddress ip = WiFi.localIP();
  Serial.println(ip);

  ipAddress = ip.toString();

}

void sendTelegramMessage() {
  String message = "SSID:  ";
  message.concat(ssid);
  message.concat("\n");
  message.concat("IP: ");
  message.concat(ipAddress);
  message.concat("\n");
  if(bot.sendMessage(CHAT_ID, message, "Markdown")){
    Serial.println("TELEGRAM Successfully sent");
  }
  Serial.println(message);
  }

void loop() {

    sendTelegramMessage();
    delay(5000);

}```
zenercurrent commented 4 years ago

hey @haorfani, is your esp8266 core still v2.4.2? Telegram had an update so you have to update to v2.5

sefasenlik commented 4 years ago

On 2.5 add client.setInsecure(); to the setup of the sketch On Sun, 10 Mar 2019, 18:09 MrTilllus, @.***> wrote: can you maybe upload your sketch because when i try to connect with my sketch from 2.5 to my wifi with core 2.4.2 it does not — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#104 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/ABfXwvj1lWPoaBYA5yEV6Oe0K5DVhpy9ks5vVUpIgaJpZM4Z9HU6 .

It works!