so im using a SIM7600E-LTE connected to an esp32, and im trying to get it to send data to firebase realtime database, so to test its functionallity i tried writing a simple script to send a message to the database and i just cant get it to work. i also tried using the TinyGsm library but that also didnt seem to work, at some point i managed to get two messages sent to the databse but ive got no clue how that happened and what version of code did that, but im prett shure it was something like this
#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 upload(String jsonData) {
//setup and bit of testing
command("AT+CGDCONT=1,\"IP\",\"everywhere\""); // Set APN
command("AT+CGATT=1");
command("AT+CHTTPSSTART", 5000);
command("AT+CSQ"); // start https service
command("AT+CHTTPSOPSE=\"DB URL\",443,2", 10000);
command("AT+CHTTPSSEND=0");
while (sim.available()) {
if (sim.find("DOWNLOAD")) break;
}
command("AT+CHTTPSSEND=\"POST\",\"/test.json\"", 15000);
sim.print(jsonData);
delay(200);
command("AT+CHTTPSRECV", 5000);
command("AT+CHTTPSCLSE", 5000);
command("AT+CHTTPSSTOP", 5000);
}
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");
upload("{\"message\":\"data test input v2\"}");
}
void loop() {
while (sim.available()) {
Serial.write(sim.read());
}
}
output
AT
OK
ATI
Manufacturer: SIMCOM INCORPORATED
Model: SIMCOM_SIM7600E-L1C
Revision: SIM7600M11_A_V2.0.1
IMEI: 862499070415105
+GCAP: +CGSM
OK
AT+CSQ
+CSQ: 18,99
OK
AT+CGDCONT=1,"IP","everywhere"
OK
AT+CGATT=1
OK
AT+CGDCONT=1,"IP","everywhere"
OK
AT+CGATT=1
OK
AT+CHTTPSSTART
OK
+CHTTPSSTART: 0
AT+CSQ
+CSQ: 18,99
OK
AT+CHTTPSOPSE=DB URL
OK
+CHTTPSOPSE: 0
AT+CHTTPSSEND=0
ERROR
AT+CHTTPSSEND="POST","/test.json"
ERROR
ata test input v2"}AT+CHTTPSRECV
ERROR
AT+CHTTPSCLSE
+CHTTPSCLSE: 0
OK
AT+CHTTPSSTOP
+CHTTPSSTOP: 0
OK