我正在尝试使用Arduino,DHT11和Telegram机器人创建监视系统。我试图发送一条消息开始,但看来arduino和电报之间的连接未建立。串行监视器打印出“电话未成功发送”消息。但是,它不会给出任何错误。请帮忙。
#include <ESP8266WiFi.h>
#include <UniversalTelegramBot.h>
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>
// Initialize Wifi connection to the router
#define WIFI_SSID "xxxxx" // input your home or public wifi name
#define WIFI_PASSWORD "xxxxxx"
// Initialize Telegram BOT
#define BOTtoken "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#define CHAT_ID "xxxxxxxxxxxxx"
//Create a new WiFi client
WiFiClientSecure client; //For ESP8266 boards
//Create a bot with the token and client
UniversalTelegramBot bot(BOTtoken, client);
void setup() {
Serial.begin(57600);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD); //try to connect with wifi
Serial.print("Connecting to ");
Serial.print(WIFI_SSID);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("Connected to ");
Serial.println(WIFI_SSID);
Serial.print("IP Address is : ");
Serial.println(WiFi.localIP());
if (bot.sendMessage(CHAT_ID, "Bot started up")){
Serial.println("TELEGRAM Successfully sent");
}
else{
Serial.println("TELEGRAM NOT Successfully sent");
}
}
void loop() {
}