完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我刚刚为 esp8266 芯片制作了自己的 PCB,我从 NodeMcu V1.0 中获取了所有原理图。据我所知,硬件与 NodeMcu 相同......
所以这是我的代码与 NodeMcu 配合良好的问题但是当我把它上传到我的主板上,除了 WiFi 外,一切正常。 当我启动 esp 作为接入点时,它显示在我手机的 wifi 列表中,但我无法连接到它。我认为它无法为我的手机分配 ip, 当我选择站模式并给它正确的 ssid 并再次连接我的手机靠近我的板的热点时,它再次识别板周围的所有站,但它无法连接对他们中的任何一个。我也用路由器测试过这个。 那么我该如何解决呢?我感谢你所有的回答 这是一个不起作用的站模式代码 代码:全选/******************************************************************* * 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 #include #include // 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 String text = bot.messages.text; String from_name = bot.messages.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.nn"; welcome += "/ledon : to switch the Led ONn"; welcome += "/ledoff : to switch the Led OFFn"; welcome += "/status : Returns current status of LEDn"; bot.sendMessage(chat_id, welcome, "Markdown"); } } } void setup() { Serial.begin(115200); // Set WiFi to station mode and disconnect from an AP if it was Previously // connected WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(100); // attempt to connect to Wifi network: Serial.print("Connecting Wifi: "); Serial.println(ssid); 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(); } } |
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
1002 浏览 1 评论
554浏览 6评论
463浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
447浏览 5评论
448浏览 4评论
422浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-29 21:55 , Processed in 1.017406 second(s), Total 45, Slave 38 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号