Send notification via telegram bot

Hi, why it come out this error with all the libraries installed?Can anyone help me to solve it?Much appreciate
The error message

  1. class WiFiClientSecure' has no member named 'setTrustAnchors
  2. 'X509List' does not name a type; did you mean 'xList'?
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>


const char* ssid = "";// Enter your WIFI SSID
const char* password = ""; // Enter your WIFI Password


#define BOTtoken "" // Enter the bottoken you got from botfather
#define CHAT_ID "" // Enter your chatID you got from chatid bot


X509List cert(TELEGRAM_CERTIFICATE_ROOT);
WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);

int const trigPin = 34;
int const echoPin = 35;
int const buzzPin = 25;
const int LED1 = 13;

void setup()
{
  Serial.begin(115200);
  configTime(0, 0, "pool.ntp.org");      
  client.setTrustAnchors(&cert);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  int a = 0;
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
    a++;
  }
  
pinMode(trigPin, OUTPUT); 
pinMode(echoPin, INPUT);
pinMode(buzzPin, OUTPUT);
pinMode(LED1 , OUTPUT);

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  bot.sendMessage(CHAT_ID, "Wifi Connected!", "");
  bot.sendMessage(CHAT_ID, "System has Started!!", "");

}
void loop()
{

int duration, distance;
digitalWrite(trigPin, HIGH);
delay(1);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;

if (distance <= 10 && distance >= 0) {
digitalWrite(buzzPin, HIGH);
//digitalWrite(LED1, HIGH);
bot.sendMessage(CHAT_ID, "ALERT! MOTION DETECTED!!", "");

} else {
digitalWrite(buzzPin, LOW);
//digitalWrite(LED1, LOW);
}

}

Your code is not compatible with the included library. Either correct the code, or use the appropriate library.

#define BOTtoken "6653814493:AA

s/b
#define BOT_TOKEN "6653814493:AA

Universal-Arduino-Telegram-Bot/examples/ESP8266/SendMessageFromEvent/SendMessageFromEvent.ino at master · witnessmenow/Universal-Arduino-Telegram-Bot · GitHub

 // attempt to connect to Wifi network:
  Serial.print("Connecting to Wifi SSID ");
  Serial.print(WIFI_SSID);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  secured_client.setTrustAnchors(&cert); // Add root certificate for api.telegram.org

secured_client
vs
client (??)

so which library should i include?

I have a related question --
is the Telegram app trustworthy?

Are you using an ESP8266 or ESP32 ?

Will the example in the link work ?
(I'm reluctant to d/l the library.)

I am using esp32

Universal-Arduino-Telegram-Bot/examples/ESP32/SendMessageFromEvent/SendMessageFromEvent.ino at master · witnessmenow/Universal-Arduino-Telegram-Bot · GitHub

Same but different?
Does it Verify ?

Im nt sure

do i need to include this with esp32?
X509List cert(TELEGRAM_CERTIFICATE_ROOT);

it shows the same error when i used secured_client
'secured_client' was not declared in this scope

It is not in the ESP32 example (link, Post No.8)

Did you copy & paste that (and add your credentials) ?

If you have reason to believe that the code is correct, then the correct library will have the missing member.

If you did not write the code, ask the author, or go to the web site where you found the code, and determine which library should be used.

1 Like

It works!! Thank you so much

thank you so much

but i hv one question
can telegram bot able to send picture also?

Would you trust an app that has a loss making business model?

Therein lies the problem, it's great while it works, but one day the investors will want their money back and at that point the unprofitable bits of the service may just disappear.

There aren't many paid push notification services. I use Pushbullet and it seems to work reliably.
It's a tough market to compete in when competitors are trying to drive you out of business by running at a loss.

Yes

Can you explain what you did to make it work
I have esp 8266 and everything I don't do doesn't work.

error: 'X509List' does not name a type

WeMos D1

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.