0

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

enter image description here

VE7JRO
2,51519 gold badges27 silver badges29 bronze badges
asked Nov 5, 2018 at 17:38
1
  • problem is, that you connected the esp8266 to Serial. now your Serial debug prints go to esp8266 and disturb it. use SoftwareSerial Commented Nov 16, 2018 at 20:56

1 Answer 1

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.

answered Nov 5, 2018 at 17:45
3
  • 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 ? Commented Nov 5, 2018 at 19:33
  • how do you power it? Commented Nov 5, 2018 at 20:45
  • I used arduino with USB power Commented Nov 5, 2018 at 21:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.