taalaay
November 5, 2018, 12:20pm
1
Hi guys,
I have question about esp8266. I checked opened Subject but I can't find any answer. I tried a few things but I failed every time.
#include <SoftwareSerial.h>
#define Nname "*******"
#define Npass "*******"
#define IP "192.168.1.9"
const byte rxPin = 2;
const byte txPin = 3;
SoftwareSerial ESP8266(rxPin,txPin);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
ESP8266.begin(115200);
ESP8266.println("AT");
delay(3000);
if(ESP8266.find("OK")){
ESP8266.println("AT+CWMODE=1");
delay(2000);
String connectionCommand=String("AT+CWJAP=\"")+Nname+"\",\""+Npass+"\"";
ESP8266.println(connectionCommand);
delay(5000);
}
}
void loop() {
// put your main code here, to run repeatedly:
ESP8266.println("AT+CIPMUX=1");
ESP8266.println("AT+CIPSTART=\"TCP\",\"192.168.1.9\",8000");
delay(1000);
String model = "GET /kanbanDB/arduino?model=1 HTTP/1.1";
ESP8266.println("AT+CIPSEND=" + String(model.length()));
delay(1000);
ESP8266.println(model);
delay(1000);
ESP8266.println("");
}
I'm connecting to the WIFI network but I cant send GET method. I could rarely send it a few times
Juraj
November 5, 2018, 12:29pm
2
add \r\n after GET line and add Host header terminated by \r\n and then an empty line with \r\n
https://tools.ietf.org/html/rfc2616
taalaay
November 5, 2018, 12:38pm
3
I have tried this code but it's not working.
ESP8266.println("AT+CIPSTART=\"TCP\",\"192.168.1.9\",8000");
delay(1000);
String model = "GET /kanbanDB/arduino?model=1 HTTP/1.1\r\n";
model+="Host: 192.168.1.9\r\n";
ESP8266.println("AT+CIPSEND=" + String(model.length()));
ESP8266.println("\r\n");
delay(1000);
ESP8266.println(model);
delay(1000);
You are still not doing it right:
String request = "GET /kanbanDB/arduino?model=1 HTTP/1.1\r\n"; //Use descriptive names
request+="Host: 192.168.1.9\r\n\r\n"; //Two CR+LF as request termination
Also look at this thread which may be helpful. Depending on the arduino you are using, you should get rid of all usage of the "String" class.
hello, thank you for advise.
I have tried many combination but still not working. I tried GET from browser, its working but I cant send from arduino.I am looking the thread
You may want to read the output from the ESP8266 module in order to figure out what goes wrong.
I think the problem is caused by the CIPSEND command I read the output from ESP the answer to CIPSEND is:⸮⸮%AM9⸮66
The answer shoul be ">"
When I add this code, "model" variable does not print from Serial monitor.
if(Serial.find(">")){
Serial.println(model);
delay(2000);
Serial.println("AT+CIPCLOSE=0");
delay(2000);
}
Juraj
November 5, 2018, 2:02pm
8
SoftwareSerial can't work at 115200 baud. use 9600, but first set the AT firmware baudrate to 9600 baud
No one can guess the rest of your code and the problem is not in the posted snippet.
taalaay
November 5, 2018, 4:54pm
10
I attached my command line example I tried most of thing but I cant send GET method
You cannot expect ppl to download a screenshot with text in order to help you, please post the text itself instead.
taalaay
November 5, 2018, 7:42pm
12
I am sorry for my ignorance.
AT+CWMODE=1
22:37:03.105 -> no change
AT+CWJAP="SUPERONLINE_WiFi_8022","rC5YGNYebuCf"
22:37:28.281 ->
22:37:28.281 -> OK
AT+CIPSTART="TCP","192.168.1.9",8000
22:38:06.904 -> OK
22:38:06.904 -> Linked
AT+CIPSEND=50
22:38:15.744 -> > GET /kanbanDB/arduino?model=1 HTTP/1.1
22:38:49.151 -> busy s...
22:39:50.603 -> ERROR
22:39:50.603 -> Unlink
Did you read the other post? I would suggest you to use a connection identifier:
AT+CIPSTART=0, "TCP","192.168.1.9",8000
AT+CIPSEND=**0,**50
Someone in the other thread also suggested to end the request with a space. And I would also consider to choose a new WiFi key since you apparently posted yours in #11 .