Chat freely about anything...

User avatar
By nimaaryamehr
#67712 I can not use the library: ESP8266TelegramBOT.h Because For all examples i have this error
how fix this error

Excuse my English is not good :)


Code: Select all
FlashledBotme.ino: In function 'void Bot_ExecMessages()':
FlashledBotme.ino:43:30: warning: unknown escape sequence: '\/' [enabled by default]
FlashledBotme.ino:47:30: warning: unknown escape sequence: '\/' [enabled by default]
FlashledBotme.ino:51:30: warning: unknown escape sequence: '\/' [enabled by default]
C:\Users\Elisum\AppData\Roaming\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\bin\xtensa-lx106-elf-ar: unable to rename 'C:\Users\Elisum\AppData\Local\Temp\build3938707344910902830.tmp/arduino.ar'; reason: File exists
Error compiling.
C:\Users\Elisum\AppData\Roaming\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\bin\xtensa-lx106-elf-ar: unable to rename 'C:\Users\Elisum\AppData\Local\Temp\build3938707344910902830.tmp/arduino.ar'; reason: File exists
Error compiling.

Sketch uses 257,319 bytes (59%) of program storage space. Maximum is 434,160 bytes.
Global variables use 41,009 bytes (50%) of dynamic memory, leaving 40,911 bytes for local variables. Maximum is 81,920 bytes.




Program :
Code: Select all/*******************************************************************
 *  this is a basic example how to program a Telegram Bot          *
 *  using TelegramBOT library on ESP8266                           *
 *                                                                 *
 *  Open a conversation with the bot, you can command via Telegram *
 *  a led from ESP8266 GPIO                                        *
 *  https://web.telegram.org/#/im?p=@FlashledBot_bot               *
 *                                                                 *
 *  written by Giancarlo Bacchio                                   *
 *******************************************************************/

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


// Initialize Wifi connection to the router
char ssid[] = ".:ELISUM:.";              // your network SSID (name)
char pass[] = "0921436505";                              // your network key



// Initialize Telegram BOT

#define BOTtoken "358230547:AAHBzHXPD000000X1j3qxTKUXEQ"  //token of FlashledBOT  ///  249578705:AAGBz2gJ3m6c8qI3bx7JrmwD4fsVwc1qS4Y
#define BOTname "Nimaaryamehr"
#define BOTusername "Nimaaryamehr_bot"

TelegramBOT bot(BOTtoken, BOTname, BOTusername);

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



/********************************************
 * EchoMessages - function to Echo messages *
 ********************************************/
void Bot_ExecMessages() {
  for (int i = 1; i < bot.message[0][0].toInt() + 1; i++)      {
    bot.message[i][5]=bot.message[i][5].substring(1,bot.message[i][5].length());
    if (bot.message[i][5] == "\/ledon") {
      digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
      bot.sendMessage(bot.message[i][4], "Led is ON", "");
    }
    if (bot.message[i][5] == "\/ledoff") {
      digitalWrite(13, LOW);    // turn the LED off (LOW is the voltage level)
      bot.sendMessage(bot.message[i][4], "Led is OFF", "");
    }
    if (bot.message[i][5] == "\/start") {
      String wellcome = "Salam be bot esp8266 saeed khoshAmadi";
      String wellcome1 = "/ledon : to switch the Led ON";
      String wellcome2 = "/ledoff : to switch the Led OFF";
      bot.sendMessage(bot.message[i][4], wellcome, "");
      bot.sendMessage(bot.message[i][4], wellcome1, "");
      bot.sendMessage(bot.message[i][4], wellcome2, "");
      Start = true;
    }
  }
  bot.message[0][0] = "";   // All messages have been replied - reset new messages
}


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

  // attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  while (WiFi.begin(ssid, pass) != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  IPAddress ip = WiFi.localIP();
  Serial.println(ip);
  bot.begin();      // launch Bot functionalities
  pinMode(2, OUTPUT); // initialize digital pin 2 as an output.
}



void loop() {
  if (millis() > Bot_lasttime + Bot_mtbs)  {
    bot.getUpdates(bot.message[0][1]);   // launch API GetUpdates up to xxx message
    Bot_ExecMessages();   // reply to message with Echo
    Bot_lasttime = millis();
  }
}



User avatar
By QuickFix
#67721 Then you obviously didn't succeed in installing the library (just like the Json-library in your other post) correctly. :idea: