2016-04-07 6 views
0

私はArduinoのESP8266に接続しています。私はArduinoと無線LANモジュールを接続したい。私はAT + CIFSRを使ってIPを探したい。シリアルモニタでATコマンドを使用してIPをプリントする方法は? telnetアプリに接続するには、Androidの携帯電話に挿入するためにIPが必要です。あなたはATコマンドにArduinoでESP8266でATコマンドを使用してシリアルモニタにIPを表示する方法は?

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

を送信していない

#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: 
} 
+0

ESPからのシリアル応答を読み取る方法あなたの質問であるべきか? ATコマンドと他のシリアル・データの読取りには特別なものはありません。 Arduinoのシリアル資料は、あなたが望むことをする方法を示しています。 –

答えて

0

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(""); 
関連する問題