To com problema para utilizar o Telegam com ESP32

da essa msg de erro mesmo atualizando a biblioteca arduinoJson para a 6.14

C: \ Usuários \ Abél \ Documentos \ Arduino \ bibliotecas \ UniversalTelegramBot \ src \ UniversalTelegramBot.cpp: 369: 11: erro: DynamicJsonBuffer é uma classe do ArduinoJson 5. Consulte arduinojson.org/upgrade para saber como atualizar seu programa para o ArduinoJson versão 6

     DynamicJsonBuffer jsonBuffer;

codigo fonte exemplo FlashLED

/*******************************************************************
* An example of bot that receives commands and turns on and off *
* an LED. *
* *
* written by Giacarlo Bacchio (Gianbacchio on Github) *
* adapted by Brian Lough *
*******************************************************************/
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>

// Initialize Wifi connection to the router
char ssid[] = "XXXXXX"; // your network SSID (name)
char password[] = "YYYYYY"; // your network key

// Initialize Telegram BOT
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get from Botfather)

WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);

int Bot_mtbs = 1000; //mean time between scan messages
long Bot_lasttime; //last time messages' scan has been done
bool Start = false;

const int ledPin = 13;
int ledStatus = 0;

void handleNewMessages(int numNewMessages) {
Serial.println("handleNewMessages");
Serial.println(String(numNewMessages));

for (int i=0; i<numNewMessages; i++) {
String chat_id = String(bot.messages[i].chat_id);
String text = bot.messages[i].text;

String from_name = bot.messages[i].from_name;
if (from_name == "") from_name = "Guest";

if (text == "/ledon") {
digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)
ledStatus = 1;
bot.sendMessage(chat_id, "Led is ON", "");
}

if (text == "/ledoff") {
ledStatus = 0;
digitalWrite(ledPin, LOW); // turn the LED off (LOW is the voltage level)
bot.sendMessage(chat_id, "Led is OFF", "");
}

if (text == "/status") {
if(ledStatus){
bot.sendMessage(chat_id, "Led is ON", "");
} else {
bot.sendMessage(chat_id, "Led is OFF", "");
}
}

if (text == "/start") {
String welcome = "Welcome to Universal Arduino Telegram Bot library, " + from_name + ".\n";
welcome += "This is Flash Led Bot example.\n\n";
welcome += "/ledon : to switch the Led ON\n";
welcome += "/ledoff : to switch the Led OFF\n";
welcome += "/status : Returns current status of LED\n";
bot.sendMessage(chat_id, welcome, "Markdown");
}
}
}


void setup() {
Serial.begin(115200);

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

// Set WiFi to station mode and disconnect from an AP if it was Previously
// connected
WiFi.mode(WIFI_STA);
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());

pinMode(ledPin, OUTPUT); // initialize digital ledPin as an output.
delay(10);
digitalWrite(ledPin, LOW); // initialize pin as off
}

void loop() {
if (millis() > Bot_lasttime + Bot_mtbs) {
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);
}

Bot_lasttime = millis();
}
}

Exibições: 603

As respostas para este tópico estão encerradas.

Respostas a este tópico

Olá.

  O erro:

"DynamicJsonBuffer é uma classe do ArduinoJson 5. Consulte arduinojson.org/upgrade para saber como atualizar seu programa para o ArduinoJson versão 6"

  Significa que seu programa é que usa comandos para a versão 5 e precisa ser modificado para ficar compatível com a versão 6.

O caminho está em:

https://arduinojson.org/v6/doc/upgrade/

Nunca fiz, não consigo te ajudar, mas...

Outra possibilidade seria usar a biblioteca 5, que deve funcionar com o seu código.

Preferivelmente use a 6. Tente achar um exemplo funcional pra ela que compile.

vlw mais uma vez ! consegui compilar com  a versão do Arduinojson 5  e eu tava tentando com a mis recente 6.14.

pra compilar esse codigo precisa de duas bibliotecas  * Arduinojson / versão 5

                                                                                       *UniversalTelegramBo/ versão 0.6.1

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço