如何在Arduino中使用带ESP8266的AT命令在串行监视器中显示IP?

如何在Arduino中使用带ESP8266的AT命令在串行监视器中显示IP?,arduino,telnet,at-command,esp8266,Arduino,Telnet,At Command,Esp8266,我正在连接Arduino的ESP8266。我想用Arduino连接wifi模块。我想使用AT+CIFSR查找IP。如何在串行监视器中使用AT命令打印IP?要连接telnet应用程序,需要在Android手机中插入IP #include "SoftwareSerial.h" String ssid = "connectify-krish"; String password = "12345678"; SoftwareSerial esp(10, 11); void setup() { int

我正在连接Arduino的ESP8266。我想用Arduino连接wifi模块。我想使用AT+CIFSR查找IP。如何在串行监视器中使用AT命令打印IP?要连接telnet应用程序,需要在Android手机中插入IP

#include "SoftwareSerial.h"
String ssid = "connectify-krish";
String password = "12345678";
SoftwareSerial esp(10, 11);
void setup() {
  int len;
  Serial.begin(9600);
  esp.begin(9600);
  reset();
  esp.println("AT");
  delay(1000);
  if (esp.find("OK")) Serial.println("Module Reset");
  esp.println("AT+RST");
  delay(1000);
  if (esp.find("OK")) Serial.println("Reset");
  esp.println("AT+RST");
  delay(1000);
  String cmd = "AT+CWJAP=\"" + ssid + "\",\"" + password + "\"";
  Serial.println(cmd);
  String site= "www.google.com";
  String ping = "AT+PING=\"" + site + "\"";
  esp.println(ping);
  if (esp.find("OK")) Serial.println("CONNECTED WIFI");
  String ip = "AT+CIFSR";
  esp.println(ping);
  if (esp.find("OK")) Serial.println("ip is");
}

void reset() {
  if(esp.available()) {
    // check if the esp is sending a message
    while(esp.available()) {
      // The esp has data so display its output to the serial window
      char c = esp.read(); // read the next character.
      Serial.write(c);
    }
  }
}

void loop() {
  // put your main code here, to run repeatedly:
}

您没有发送AT命令

String ip = "AT+CIFSR";
esp.println(ping);
if (esp.find("OK")) Serial.println("ip is");
应该是

String ip = "AT+CIFSR";
esp.println(ip);
Serial.print("ip is ");
// Loop through all the data returned
while(esp.available()) {
      // The esp has data so display its output to the serial window
      char c = esp.read(); // read the next character.
      Serial.write(c);
}
Serial.println("");

您的问题是如何读取ESP的串行响应?与读取任何其他串行数据相比,AT命令没有什么特别之处。Arduino系列文档向您展示了如何做您想做的事情。