0
我正在連接到Arduino中的ESP8266。我想連接WiFi模塊與Arduino。我想用AT + CIFSR找到IP。如何在串行監視器中使用AT命令打印IP?要連接到遠程登錄應用程序,需要在Android手機中插入IP。如何使用AT命令在Arduino中使用ESP8266在串行監視器中顯示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:
}
是你的問題如何閱讀從ESP串行迴應? AT命令與讀取任何其他串行數據沒有什麼特別之處。 Arduino的串行文件顯示你如何做你想做的。 –