I am working on ESP8266 and I want to send a GET request with AT command to my localhost but I failed every time. Can you help me solve this problem please? Thank you for interest! I attached my terminal code and my code:
#define ag_ismi "SUPERONLINE_WiFi_8022"
#define ag_sifresi "rC5YGNYebuCf"
#define IP "192.168.1.9"
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("AT");
delay(3000);
if(Serial.find("OK")){
Serial.println("AT+CWMODE=1");
delay(2000);
String baglantiKomutu=String("AT+CWJAP=\"")+ag_ismi+"\",\""+ag_sifresi+"\"";
Serial.println(baglantiKomutu);
delay(5000);
}
}
void loop() {
// put your main code here, to run repeatedly:
delay(60000);
Serial.println("AT+CIPMUX=1");
Serial.println("AT+CIPSTART=\"TCP\",\"192.168.1.9\",8000");
delay(1000);
String model = "GET /kanbanDB/arduino?model=1 HTTP/1.1";
//model+="Host: 192.168.1.9:8000\r\n\r\n";
model+="r\n\r\n";
Serial.println("AT+CIPSEND=" + String(model.length()));
Serial.println("\r\n\r\n");
delay(1000);
Serial.println(model);
Serial.println("\r\n\r\n");
delay(1000);
Serial.println("");
}
-
problem is, that you connected the esp8266 to Serial. now your Serial debug prints go to esp8266 and disturb it. use SoftwareSerialJuraj– Juraj ♦2018年11月16日 20:56:42 +00:00Commented Nov 16, 2018 at 20:56
1 Answer 1
It should be
String model = "GET /kanbanDB/arduino?model=1 HTTP/1.1\r\n";
model+="Host: 192.168.1.9\r\n\r\n";
remove Serial.println("\r\n\r\n");
before Serial.println(model);
it is send before GET line
Serial.println("AT+CIPSTART=\"TCP\",\"192.168.1.9\",8000");
String model = "GET /kanbanDB/arduino?model=1 HTTP/1.1\r\n";
model+= "Host: 192.168.1.9\r\n\r\n";
Serial.print("AT+CIPSEND=");
Serial.println(model.length());
delay(1000);
Serial.print(model);
delay(1000);
EDIT: Remove debug prints to Serial or use SoftwareSerial to connect the esp8266 to Uno. Now the debug prints are sent to esp8266 mixed with AT commands and data. For SoftwareSerial change the default baud rate of the AT firmware.
-
I tried this code but its also not working. when I run GET /kanbanDB/arduino?model=1 HTTP/1.1 code, if I send first time wifi module waiting 30 second and send requets but second time I run this code it failed. that failure is about power supply ?Can Talay– Can Talay2018年11月05日 19:33:19 +00:00Commented Nov 5, 2018 at 19:33
-
-
I used arduino with USB powerCan Talay– Can Talay2018年11月05日 21:33:50 +00:00Commented Nov 5, 2018 at 21:33