Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1793

SIM7600E + ESP32: Unable to Send HTTPS POST to Firebase, HTTP_PEER_CLOSED

$
0
0

Got a project using ESP32 with SIM7600E 4g LTE module, and im trying to get it to send data to firebase realtime database. i can get it to successfully initialise and connect to cellular network. ive tested it sending sms and pining other servers. Whenever I try to post something to the database ,i get something like +HTTP_PEER_CLOSED. i thought this was because firebase was rejecting http requests, so i tried sending it as a HTTPS request, and failed at this too. Honestly been stuck on this for a week and could use some help really badly

#include <Arduino.h>#include <HardwareSerial.h>const long Baudrate = 115200;const char RX_Pin = 16;const char TX_Pin = 17;HardwareSerial sim(1);void command(String command, unsigned long timeout = 1000) {    sim.println(command);    unsigned long startTime = millis();    while (millis() - startTime < timeout) {        if (sim.available()) {            String response = sim.readString();            Serial.println(response);            break;        }    }}void SetHTTPS() {    command("");}void upload() {    command("AT+CSSLCFG=\"sslversion\",0,3");    command("AT+CSSLCFG=\"ignorelocaltime\",0,1");    command("AT+CSSLCFG=\"seclevel\",0,0");    command("AT+HTTPINIT", 5000);    command("AT+HTTPPARA=\"URL\",\"https://DB-URL-STUFF.firebasedatabase.app/test.json?auth=AUTH-KEY\"");    command("AT+HTTPPARA=\"CONTENT\",\"application/json\"");    sim.println("AT+HTTPDATA=35,10000");    delay(3000);    if (sim.available()) {        String response =  sim.readString();        if (response.indexOf("DOWNLOAD") != -1) {            Serial.println("Sending JSON...");            sim.println("{\"message\":\"test from SIM7600\"}");            delay(1000);            sim.write(26);            delay(2000);        }    }    command("AT+HTTPACTION?");    command("AT+HTTPACTION=1", 5000);    command("AT+HTTPREAD");    command("AT+HTTPTERM");}void setup() {    Serial.begin(115200);    sim.begin(Baudrate, SERIAL_8N1, RX_Pin, TX_Pin);    command("AT"); // test stuff    command("ATI"); // module status stuff    command("AT+CSQ"); // signal    command("AT+CGDCONT=1,\"IP\",\"everywhere\"");    command("AT+CGATT=1");    command("AT+CGACT=1,1");    command("AT+NETOPEN");    delay(100);    upload();}void loop() {    while (sim.available()) {        Serial.write(sim.read());    }}

Output

ATOKATIManufacturer: SIMCOM INCORPORATEDModel: SIMCOM_SIM7600E-L1CRevision: SIM7600M11_A_V2.0.1IMEI: 862499070415105+GCAP: +CGSMOKAT+CSQ+CSQ: 15,99OKAT+CGDCONT=1,"IP","everywhere"OKAT+CGATT=1OKAT+CGACT=1,1OKAT+NETOPEN+IP ERROR: Network is already openedERRORAT+CSSLCFG="sslversion",0,3OKAT+CSSLCFG="ignorelocaltime",0,1OKAT+CSSLCFG="seclevel",0,2ERRORAT+HTTPINITOKAT+HTTPPARA="URL","https://DB-URL-STUFF.firebasedatabase.app/test.json?auth=AUTH-KEY"OKAT+HTTPPARA="CONTENT","application/json"OKSending JSON...{"message":"test from SIM7600"}AOKAT+HTTPACTION=1OK+HTTPACTION: 1,400,77AT+HTTPREADERRORAT+HTTPTERMOK

Viewing all articles
Browse latest Browse all 1793

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>