我正在尝试向AT
发送ESP8266
个命令,以便通过Wifi与互联网建立联系。
当我在串行监视器上发送AT
和AT+RST
命令时,我得到了正常的响应,看起来很完美。
然后我发送AT+CWLAP
以获取正在正确执行的可用wifi网络列表。
AT+CWLAP
+CWLAP:(3,"Moto",-42,"a4:70:d6:7a:fa:6c",1,25,0)
+CWLAP:(4,"PRANJAL",-95,"1c:a5:32:3d:f5:c4",1,-16,0)
+CWLAP:(2,"VIHAN",-94,"c8:3a:35:2f:1d:81",1,-21,0)
+CWLAP:(3,"Tenda",-93,"c8:3a:35:20:a9:b1",9,-4,0)
OK
然后我发送了AT+CWMODE?
,这也很完美。
AT+CWMODE?
+CWMODE:1
OK
现在我正在尝试使用此命令将ESP8266
与上面列出的Wifi连接,它正在串行监视器上发送错误。
AT + CWJAP_DEF = “摩托”, “reset1234”
错误
⸮=IRe"Moto","reset1234"
ERROR
有谁能告诉我这个问题可能是什么原因?
#include "SoftwareSerial.h"
SoftwareSerial esp8266(2, 3); // RX, TX
void setup()
{
Serial.begin(9600); // serial port used for debugging
esp8266.begin(9600); // your ESP's baud rate might be different
}
void loop()
{
if(esp8266.available()) // check if the ESP is sending a message
{
while(esp8266.available())
{
char c = esp8266.read(); // read the next character.
Serial.write(c); // writes data to the serial monitor
}
}
if(Serial.available())
{
delay(10); // wait to let all the input command in the serial buffer
// read the input command in a string
String cmd = "";
while(Serial.available())
{
cmd += (char)Serial.read();
}
// send to the esp8266
esp8266.println(cmd);
}
}
答案 0 :(得分:5)
目前正式的AT命令集似乎记录在 https://github.com/espressif/ESP8266_AT/wiki/AT_Description 上
http://espressif.com/sites/default/files/documentation/4a-esp8266_at_instruction_set_en.pdf
https://www.itead.cc/wiki/ESP8266_Serial_WIFI_Module#AT_Commands
如果要将模块配置为客户端,即连接到接入点,则必须发送以下AT命令(11500波特8N1,CR-LF线路终端):
AT+RST
AT+CWMODE=3
(1只是“Station”(wifi客户端),3是混合模式“Station and Access-Point”,两者都应该有效)AT+CWJAP="Moto","reset1234"
AT+CWJAP_CUR="Moto","reset1234"
(临时)或AT+CWJAP_DEF="Moto","reset1234"
(已存储)供参考,“成功案例”(带有USB-UART的ESP8266模块,软件:HTerm,带WPA2的接入点(经过TKIP / CCMP测试)):
AT<\r><\r><\n><\r><\n>
OK<\r><\n>
AT+RST<\r><\r><\n><\r><\n>
OK<\r><\n>
<\r><\n>
ets Jan 8 2013,rst cause:2, boot mode:(3,6)<\r><\n>
<\r><\n>
load 0x40100000, len 1856, room 16 <\r><\n>
tail 0<\r><\n>
chksum 0x63<\r><\n>
load 0x3ffe8000, len 776, room 8 <\r><\n>
tail 0<\r><\n>
chksum 0x02<\r><\n>
load 0x3ffe8310, len 552, room 8 <\r><\n>
tail 0<\r><\n>
chksum 0x79<\r><\n>
csum 0x79<\r><\n>
<\r><\n>
2nd boot version : 1.5<\r><\n>
SPI Speed : 40MHz<\r><\n>
SPI Mode : DIO<\r><\n>
SPI Flash Size & Map: 32Mbit(512KB+512KB)<\r><\n>
jump to run user1 @ 1000<\r><\n>
<\r><\n>
??r?d?l<18>?<31><\0><\f>?l`<3>??s?l?<28>?<19>?<4><4><4>$ <2>??r?$<4>??<27>?<4><4>ll`<3>r$?<18>?"<\0>????"<4>l?cs|<\f>?`?22???<27>BB<18>c??o??<18>NN?<16><2><\0><2>d$??<2>d??<\0>?<4>d??<\0>ll????d??l`<2>?<2>N?<\0>????"<4>d??<28>p<4><4><2><2>???"b<4>$<4>?"prlrl<\r><\n>
Ai-Thinker Technology Co. Ltd.<\r><\n>
<\r><\n>
ready<\r><\n>
WIFI DISCONNECT<\r><\n>
AT+CWMODE?<\r><\r><\n>+CWMODE:3<\r><\n>
<\r><\n>
OK<\r><\n>
AT+CWJAP_CUR="Moto","reset1234"<\r><\r><\n>
WIFI CONNECTED<\r><\n>
WIFI GOT IP<\r><\n>
<\r><\n>
OK<\r><\n>
AT+CIFSR<\r><\r><\n>+CIFSR:APIP,"0.0.0.0"<\r><\n>
+CIFSR:APMAC,"00:00:00:00:00:00"<\r><\n>
+CIFSR:STAIP,"0.0.0.0"<\r><\n>
+CIFSR:STAMAC,"00:00:00:00:00:00"<\r><\n>
<\r><\n>
OK<\r><\n>
AT+GMR<\r><\r><\n>AT version:1.1.0.0(May 11 2016 18:09:56)<\r><\n>
SDK version:1.5.4(baaeaebb)<\r><\n>
Ai-Thinker Technology Co. Ltd.<\r><\n>
Jun 13 2016 11:29:20<\r><\n>
OK<\r><\n>
这也适用于mode = 1。
<小时/> 重大改写。
要测试的问题和想法:
⸮
的字节代码是什么 - 是两个字节0x2E2E?与我的评论相反,也许arduino确实有影响力(时间?)。尝试通过
来排除这一点(列表的末尾,否则没有代码:)
loop(){
if( esp8266.available() )
Serial.write(esp8266.read());
if( Serial.available() )
esp8266.write(Serial.read());
}
答案 1 :(得分:-1)
好的!我只是尝试连接不同的wifi,它与它连接。这是移动热点的一些问题。