我已经把阿杜伊诺和ESP8266联系起来了
Arduino引脚2连接到ESP的Tx Arduino引脚3通过分压器Arduino GND连接到ESP的Rx连接到ESP的GND Arduino 3v3连接到ESP的CH_PD
我已使用1117电压调节器为ESP8266供电
当我最初购买ESp8266时,它运行正常,但现在它显示了无穷无尽的垃圾价值……
arduino是用以下代码编写的
#include <SoftwareSerial.h>
SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
// This means that you need to connect the TX line from the esp to the Arduino's pin 2
// and the RX line from the esp to the Arduino's pin 3
void setup()
{
Serial.begin(9600);
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())
{
// The esp has data so display its output to the serial window
char c = esp8266.read(); // read the next character.
Serial.write(c);
}
}
if(Serial.available())
{
// the following delay is required because otherwise the arduino will read the first letter of the command but not the rest
// In other words without the delay if you use AT+RST, for example, the Arduino will read the letter A send it, then read the rest and send it
// but we want to send everything at the same time.
delay(1000);
String command="";
while(Serial.available()) // read the command character by character
{
// read one character
command+=(char)Serial.read();
}
esp8266.println(command); // send the read character to the esp8266
}
}发布于 2015-06-28 21:58:42
您的esp8266可能以56000或115200的波特率工作,而不是9600。这将导致读取垃圾。
如果是115200,它将不能在softwareSerial的普通数字引脚上工作。
如果是较旧的电路板,则可以尝试更改为56000:
esp8266.begin(56000); // your esp's baud rate might be different否则,您将需要将esp8266连接到HardwareSerial端口
Serial.begin(115200);发布于 2017-10-24 02:11:49
代码看起来没问题,但你应该看看你的ESP8266波特率可能不一样。检查以下内容:
发布于 2017-11-20 18:16:10
上传代码并检查串行监视器是否有任何特定波特率的响应,如果您没有得到任何特定波特率的响应,则更改波特率,直到您得到响应。对于少数模块,默认波特率将为57600。因此,请根据它进行检查。
您可以使用上面给出的代码并更改esp8266.begin(56000);的波特率,将波特率更改为9600、56000、112500等,并以9600波特率检查串行监视器。
Serial.begin(9600);您将在显示器上得到响应,并尝试通过将3.3v连接到RST引脚1-2秒来重置wifi模块。希望能有所帮助。
https://stackoverflow.com/questions/30731584
复制相似问题