I'm working on a project with Arduino UNO that needs connection with a cloud server, that is why I'm using ESP8266 module.
I'm already connecting to wi-fi and making GET and POST request but my problem is get the response from these requests.
Here is my code:
/* Doing all these steps to make the request
AT+RST
AT+CWMODE=1
AT+CWJAP="MyNetwork","MyPassword"
AT+CIPMUX=1
AT+CIPSTART=0,"TCP","myserver.com.br",80
AT+CIPSEND=0,270
*/
String data = "data=example";
String command = "POST /webservice/v1/dispositivo/atualizar_data_requisicao HTTP/1.1\r\n";
comando += "Host: " + SERVER + "\r\n";
comando += "User-Agent: Arduino/1.0\r\n";
comando += "Connection: Close\r\n";
comando += "Content-Type: application/x-www-form-urlencoded;\r\n";
comando += "Content-Length: " + String(data.length()) + "\r\n\r\n";
comando += data;
esp8266.println(command);
delay(2000);
String response;
while(esp8266.available()) {
response += esp8266.readStringUntil('\r');
}
Serial.print("Request response: ");
Serial.println(response);
When I run this code the only response I can get is something like:
Recv 270 bxt⸮⸮C⸮
SEND OK
+IPD,0.569:HTTP/1.0 200 OK
But I was expecting a JSON.
Can someone tell me what I am doing wrong and how can I resolve it?
Edit.
Ok, after Code Gorilla helps me (Thank you so much) and a lot of research what I did was program Arduino UNO to send some commands that I invented to serial and program ESP8266 to read the serial and, depending of the command that it reads, do requests and stuff.
ESP8266 is a lot easyer to make requests and have a lot of others possibilities, like HTTPS requests, that you can't do using AT Commands.
When I create this ask I didn't know that I could program directly in ESP8266, but when Code Gorilla told me about it and helps me with some articles I could finally continue with my project.