如何在 Arduino 中使用 AT 命令和 ESP8266 在串口监视器中显示 IP?

How to display IP in serial monitor using AT command with ESP8266 in Arduino?

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

中插入 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("");