我的Arduino董事会和我的电报频道之间的连接不起作用
我试图将LDR传感器连接到Telegram Bot,以便我知道灯光是否绊倒,但似乎绊倒的消息没有通过。我试图重新启动芯片,但是它不断显示“ TestConnection Nok”,有人可以帮助我看看是否有解决此问题的问题?以下是我的Arduino使用的代码。
#include <WiFiClient.h> //CLIENT LIBRARY
#include <ESP8266WebServer.h> //WEBSERVICER LIBRARY
#include <ESP8266HTTPClient.h> //HTTP CLIENT LIBRARY
#include "CTBot.h" //TELEGRAM BOT LIBRARY
CTBot myBot; //INITIALIZE TELEGRAM BOT VARIABLE
String ssid = "CGA-Farm" ; // ASSIGN SSID VARIABLE WITH WIFI SSID
String pass = "0003606367"; // ASSIGN PASS VARIABLE WITH WIFI PASSWORD
String token = "1715253121:AAHqI4O2mt11ono-wFQ-_p5UfVpu0OeekeY"; // TELEGRAM BOT TOKEN RETRIEVED FROM BOTFATHER
int CNT = 0;
void setup() {
Serial.begin(9600);
Serial.println("Starting TelegramBot...");
myBot.wifiConnect(ssid, pass); // CONNECT ESP TO ACCESS POINT
myBot.setTelegramToken(token); // SET TELEGRAM BOT TOKEN
if (myBot.testConnection())// DEBUG CONNECTION
Serial.println("\ntestConnection OK");
else
Serial.println("\ntestConnection NOK");
}
void loop() {
float reading = analogRead(A0);
Serial.println(reading);
delay(1000);
if (reading < 800)
{
if (CNT < 1)
{
Serial.println("No light!");
myBot.sendMessage(-1001412490907,"GR1 Zone1 tripped!");
CNT = CNT + 1;
}
} else
{
CNT = 0;
}
}
Im trying to connect a ldr sensor to telegram bot, so that i know if the lights are tripping or not, but it seems like the tripped messages aren't going through. I tried to restart the chip, but it keeps showing "testconnection NOK"Can someone help me to see if there are anyways to troubleshoot this issue? Below is the code used for my arduino.
#include <WiFiClient.h> //CLIENT LIBRARY
#include <ESP8266WebServer.h> //WEBSERVICER LIBRARY
#include <ESP8266HTTPClient.h> //HTTP CLIENT LIBRARY
#include "CTBot.h" //TELEGRAM BOT LIBRARY
CTBot myBot; //INITIALIZE TELEGRAM BOT VARIABLE
String ssid = "CGA-Farm" ; // ASSIGN SSID VARIABLE WITH WIFI SSID
String pass = "0003606367"; // ASSIGN PASS VARIABLE WITH WIFI PASSWORD
String token = "1715253121:AAHqI4O2mt11ono-wFQ-_p5UfVpu0OeekeY"; // TELEGRAM BOT TOKEN RETRIEVED FROM BOTFATHER
int CNT = 0;
void setup() {
Serial.begin(9600);
Serial.println("Starting TelegramBot...");
myBot.wifiConnect(ssid, pass); // CONNECT ESP TO ACCESS POINT
myBot.setTelegramToken(token); // SET TELEGRAM BOT TOKEN
if (myBot.testConnection())// DEBUG CONNECTION
Serial.println("\ntestConnection OK");
else
Serial.println("\ntestConnection NOK");
}
void loop() {
float reading = analogRead(A0);
Serial.println(reading);
delay(1000);
if (reading < 800)
{
if (CNT < 1)
{
Serial.println("No light!");
myBot.sendMessage(-1001412490907,"GR1 Zone1 tripped!");
CNT = CNT + 1;
}
} else
{
CNT = 0;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您的错误在序列上。Begin(9600),因为Arduino的波特率与电报机器人不兼容。尝试使用此数字更改值9600:
Maybe your error is in the Serial.begin(9600) because the baud rate of the Arduino is not compatible with the Telegram bot. Try to change the value 9600 with this number :