Hi
I’m interfacing MC60 with esp32 and trying to send http post request using arduino IDE.
I followed the HTTP_Application _Note procedure but I have no luck.
I’ll be very appreciated if someone can help me with this issue.
this is my code and arduino serial monitor output
#define RXD2 17
#define TXD2 16
#include <ArduinoJson.h>
void setup() {
Serial.begin(115200);
delay(500);
Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2);
delay(500);
while (!Serial) {}
while (!Serial2) {}
Serial.println(">> Start...");
Serial2.println("AT");
Serial.println(Serial2.readString());
delay(500);
Serial2.println("ATE1");
Serial.println(Serial2.readString());
delay(500);
Serial2.println("ATI");
Serial.println(Serial2.readString());
delay(500);
Serial2.println("AT+CMEE=2");
Serial.println(Serial2.readString());
delay(500);
Serial2.println("AT+QIDEACT");
Serial.println(Serial2.readString());
delay(500);
Serial2.println("AT+QIFGCNT=0");
Serial.println(Serial2.readString());
delay(500);
Serial2.println("AT+QICSGP=1,\"mcinet\"");
Serial.println(Serial2.readString());
delay(500);
Serial2.println("AT+QIREGAPP");
Serial.println(Serial2.readString());
delay(500);
Serial2.println("AT+QIACT");
Serial.println(Serial2.readString());
delay(2000);
Serial2.println("AT+QHTTPCFG=\"requestheader\",1");
Serial.println(Serial2.readString());
delay(500);
Serial2.println("AT+QHTTPCFG=\"responseheader\",1");
Serial.println(Serial2.readString());
delay(500);
Serial2.println("AT+QHTTPURL=16");
Serial.println(Serial2.readString());
delay(1000);
Serial2.println("http://ptsv2.com");
Serial.println(Serial2.readString());
delay(500);
Serial2.println("AT+QHTTPPOST=192");
String response = Serial2.readString();
Serial.println(response);
delay(100);
if ( response.indexOf("CONNECT")>0 ) {
Serial2.print("POST /t/ehya/post HTTP/1.1\r\n");//28
Serial2.print("Host: 216.239.36.21\r\n");//21
Serial2.print("Accept: */*\r\n");//13
Serial2.print("UserAgent: Fire-Gateway\r\n");//25
Serial2.print("Connection: Keep-Alive\r\n");//24
Serial2.print("Content-Type: application/json\r\n");//32
Serial2.print("Content-Length: 25\r\n");//20
Serial2.print("\r\n");//2
Serial2.print("{\"message\":\"helloworld\"}");//24
Serial2.print("\x1A");//3
Serial.println("==============================================");
Serial2.println("AT+QHTTPREAD=30");
Serial.println(Serial2.readString());
delay(3000);
Serial.println("==============================================");
Serial2.println("AT+QIDEACT");
Serial.println(Serial2.readString());
delay(100);
Serial.println("End of the transmission");
} else {
Serial.println("Failed");
}
}
void loop() {
}
>> Start...
AT
OK
ATE1
OK
ATI
Quectel_Ltd
Quectel_MC60
Revision: MC60CAR01A13
OK
AT+CMEE=2
OK
AT+QIDEACT
DEACT OK
AT+QIFGCNT=0
OK
AT+QICSGP=1,"mcinet"
OK
AT+QIREGAPP
OK
AT+QIACT
OK
AT+QHTTPCFG="requestheader",1
OK
AT+QHTTPCFG="responseheader",1
OK
AT+QHTTPURL=16
CONNECT
OK
AT+QHTTPPOST=192
CONNECT
==============================================
==============================================
+CME ERROR: http response fail
AT+QIDEACT
DEACT OK
End of the transmission