I want to send a POST request from a SIM800L module to firebase. So far I have only got the error 603, which tells me that I have no access right?
When I send the same request from Postman installed on my laptop it works fine, read and write access is set to true.
Do I have to send some kind of authentification token with the request or something?
Thanks in advance
This is the code for the arduino controlling the SIM800L module
#define SIM800L_RX 27
#define SIM800L_TX 26
#define SIM800L_PWRKEY 4
#define SIM800L_RST 5
#define SIM800L_POWER 23
String apn = "internet.eplus.de"; //APN
String apn_u = "eplus"; //APN-Username
String apn_p = "gprs"; //APN-Password
String url = "https://benchmark-7913c-default-rtdb.europe-west1.firebasedatabase.app/.json"; //URL of Server
void setup()
{
pinMode(SIM800L_POWER, OUTPUT);
digitalWrite(SIM800L_POWER, HIGH);
Serial.begin(115200);
Serial.println("ESP32+SIM800L AT CMD Test");
Serial2.begin(9600, SERIAL_8N1, SIM800L_TX, SIM800L_RX);
delay(15000);
while (Serial2.available()) {
Serial.write(Serial2.read());
}
delay(2000);
gsm_config_gprs();
gsm_http_post("{\"test\" : \"true\"}");
Serial.println("Done");
}
void loop() {
}
void gsm_http_post( String postdata) {
Serial.println(" --- Start GPRS & HTTP --- ");
gsm_send_serial("AT+SAPBR=1,1");
gsm_send_serial("AT+SAPBR=2,1");
gsm_send_serial("AT+HTTPINIT");
gsm_send_serial("AT+HTTPPARA=CID,1");
gsm_send_serial("AT+HTTPPARA=\"URL\"," + url);
gsm_send_serial("AT+HTTPPARA=CONTENT,application/x-www-form-urlencoded");
gsm_send_serial("AT+HTTPDATA=192,5000");
gsm_send_serial(postdata);
gsm_send_serial("AT+HTTPACTION=1");
gsm_send_serial("AT+HTTPREAD");
gsm_send_serial("AT+HTTPTERM");
gsm_send_serial("AT+SAPBR=0,1");
}
void gsm_config_gprs() {
Serial.println(" --- CONFIG GPRS --- ");
gsm_send_serial("AT+SAPBR=3,1,Contype,GPRS");
gsm_send_serial("AT+SAPBR=3,1,APN," + apn);
if (apn_u != "") {
gsm_send_serial("AT+SAPBR=3,1,USER," + apn_u);
}
if (apn_p != "") {
gsm_send_serial("AT+SAPBR=3,1,PWD," + apn_p);
}
}
void gsm_send_serial(String command) {
Serial.println("Send ->: " + command);
Serial2.println(command);
long wtimer = millis();
while (wtimer + 3000 > millis()) {
while (Serial2.available()) {
Serial.write(Serial2.read());
}
}
Serial.println();
}
It seems you are adding
.json
onto the end of the URL before assigning a database location. The error 603 simply means that the location you are trying to access simply does not exist.Example URL:
https://docs-examples.firebaseio.com/rest/saving-data/fireblog/posts.json
Documentation: https://firebase.google.com/docs/database/rest/retrieve-data