2016-04-07 14 views
0

Ich verbinde mich mit einem ESP8266 in Arduino. Ich möchte das WLAN-Modul mit Arduino verbinden. Ich möchte die IP mit AT + CIFSR finden. Wie drucke ich die IP mit einem AT-Befehl im seriellen Monitor? Um eine Verbindung mit einer Telnet-App herzustellen, muss die IP-Adresse in ein Android-Telefon eingefügt werden.Wie IP im seriellen Monitor mit AT-Befehl mit ESP8266 in Arduino anzuzeigen?

#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

Ist Ihre Frage sein sollte, wie die Serien Antwort des ESP zu lesen? Es gibt nichts Besonderes an dem AT-Befehl gegenüber dem Lesen anderer serieller Daten. Die Arduino Serial-Dokumentation zeigt Ihnen, wie Sie tun können, was Sie wollen. –

Antwort

0

Sie senden nicht den AT-Befehl

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