jsoniotesp32http-status-code-301sim800l

HTTP json post on SİM800L problem. HTTPACTION responses are 301, 603 and 606


#include \<SoftwareSerial.h\>

String apn = "internet";               //APN
String apn_u = "";                     //APN-Username
String apn_p = "";                     //APN-Password
String url = "https://airpm.io/denek/GetData";  //URL of Server - Website is https://

SoftwareSerial mySerial(14, 12); // sim800l_TX_pin, sim800l_RX_pin
int counter = 0;
void setup()
{
    Serial.begin(9600);
    Serial.println("SIM800 AT CMD Test");
    mySerial.begin(9600);
    delay(5000);
    while (mySerial.available()) {
        Serial.write(mySerial.read());
    }
    delay(2000);
    configure_gprs();
}

void loop() {
    counter++;
    String data = String(counter); //write your data here
    send_to_server("{"KEY":" + data + "}");
    delay(2000);
}
void send_to_server( String data) {
    String sendURL = url;
    Serial.println(" --- Start GPRS & HTTP --- ");
    send_to_serial("AT+SAPBR=1,1");
    send_to_serial("AT+SAPBR=2,1");
    send_to_serial("AT+HTTPINIT");
    send_to_serial("AT+HTTPPARA=CID,1");
    send_to_serial("AT+HTTPPARA=URL," + sendURL);
    send_to_serial("AT+HTTPPARA=CONTENT,application/json");
    send_to_serial("AT+HTTPDATA=" + String(data.length()) + ",10000");
    send_to_serial(data);
    //send_to_serial("AT+HTTPSSL=1");
    send_to_serial("AT+HTTPACTION=1");
    send_to_serial("AT+HTTPREAD");
    send_to_serial("AT+HTTPTERM");
    send_to_serial("AT+SAPBR=0,1");
}

//AT+CGACT=1,1
// "AT+CGDCONT=1,"IP","\<APN\>","0.0.0.0",0,0"

// "AT+CGDNSIP=1,"\<PRIMARY_DNS\>","\<SECONDARY_DNS\>""

//  send_to_serial("AT+HTTPSSL=1");

void configure_gprs() {
    Serial.println(" --- CONFIG GPRS --- ");
    send_to_serial("AT+SAPBR=3,1,Contype,GPRS");
    send_to_serial("AT+SAPBR=3,1,APN," + apn);
    if (apn_u != "") {
        send_to_serial("AT+SAPBR=3,1,USER," + apn_u);
    }
    if (apn_p != "") {
        send_to_serial("AT+SAPBR=3,1,PWD," + apn_p);
    }
}

void send_to_serial(String command) {
    Serial.println("Send -\>: " + command);
    mySerial.println(command);
    long wtimer = millis();
    while (wtimer + 5000 \> millis()) {
        while (mySerial.available()) {
            Serial.write(mySerial.read());
        }
    }
    Serial.println();

}

I tried to post json data to a website on simcard(SIM800L). The website is https:// When I put this line send_to_serial("AT+HTTPSSL=1"); out of comment, I get 606 error. When its in comment, I get 603 error. When send_to_serial("AT+HTTPSSL=1"); line is in comment and When I use http:// url I get 301 error.

I use ESP32-Wroom-32D, not an arduino(ATMEL)


Solution

  • I found the problem, The SIM800L has TLS1.0 but our website has TLS1.2. So, I lowered the website's TLS level. It worked.