A9g HTTP POST and HTTP GET AT Commands

Hi guys, I am facing a issue when trying to make HTTP Post and HTTP Get Commands using A9G Module with arduino Meg. I Want to post data to firebase realtime database and also read data from the same database using A9g GPRS internet connectivity but my code cant seem to work and i dont know whats the problem, and i am always getting CME error 58. could you please help me. this is the code:

#include <SoftwareSerial.h>

SoftwareSerial A9GSerial(10, 11); // RX, TX

void setup() {
    Serial.begin(115200);
    A9GSerial.begin(115200);
    delay(5000);
    
}

void loop() {
    // information to be posted
    float temperature = 25.5;
    float humidity = 60.0;}


void initializeA9G() {
    sendATCommand("AT");
    delay(5000);
    sendATCommand("AT+CFUN=1");  // Enable full functionality (disable airplane mode)
    delay(5000);
}

bool checkNetworkRegistration() {
    sendATCommand("AT+CREG?");
    delay(1000);

    // Check the response for network registration status

    if (A9GSerial.find("+CREG: 1,1") || A9GSerial.find("+CREG: 0,5")) {
        return true;
    } else {
        return false;
    }
}

bool attachGPRS() {
    sendATCommand("AT+CGATT=1");
    delay(5000);

    // Check if GPRS is attached
    if (A9GSerial.find("+CGATT: 1")) {
        return true;
    } else {
        return false;
    }
}

bool connectToInternet() {
    sendATCommand("AT+CGDCONT=1,\"IP\",\"m-internet\"");
    delay(2000);

    sendATCommand("AT+CGACT=1,1");
    delay(5000);

    // Check if PDP activation is successful
    if (A9GSerial.find("OK")) {
        return true;
    } else {
        return false;
    }
}

bool sendDataToFirebase(float temperature, float humidity) {
    String firebaseURL = "https://base-de-dados-mmaip-default-rtdb.firebaseio.com/sensorData"; 

    // Create JSON data
    String jsonData = "{\"temperature\":" + String(temperature, 2) + ", \"humidity\":" + String(humidity, 2) + "}";

    sendATCommand("AT+HTTPINIT");
    delay(2000);

    sendATCommand("AT+HTTPPARA=\"CID\",1");
    sendATCommand("AT+HTTPPARA=\"URL\",\"" + firebaseURL + "\"");
    sendATCommand("AT+HTTPPARA=\"CONTENT\",\"application/json\"");
    sendATCommand("AT+HTTPDATA=" + String(jsonData.length()) + ",10000");
    sendATCommand(jsonData);
    sendATCommand("AT+HTTPACTION=1");
    delay(15000);

    // Check if HTTP POST was successful
    if (A9GSerial.find("HTTPACTION: 1,200")) {
        return true;
    } else {
        return false;
    }
}

void sendATCommand(String command) {
    A9GSerial.println(command);
    delay(500);

    Serial.print("Command: ");
    Serial.println(command);

    while (A9GSerial.available()) {
        char c = A9GSerial.read();
        Serial.print(c);
    }

    Serial.println();
}

Cellphone here.... Try Google on "CME error 58"!

I did it... it is a network error. I checked everything related to gprs activation on my code and i always get positive feedback

Is there no further expalantion what's wrong/missing etc?
We are at the edge of my experience by now. The last suggestion is to look for deeper/ more detailed information.

this is what i get from the serial monitor:

11:38:44.017 -> Command: AT

11:38:44.017 -> AT

11:38:44.017 ->

11:38:44.017 -> OK

11:38:44.017 ->

11:38:49.444 -> Command: AT+CFUN=1

11:38:49.444 -> AT+CFUN=1

11:38:49.444 ->

11:38:49.444 -> OK
11:38:55.003 ->

11:39:00.552 -> Command: AT+CGDCONT=1,"IP","m-internet"

11:39:00.552 -> AT+CGDCONT=1,"IP","m-internet"

11:39:00.552 -> OK
1:39:06.118 -> Command: AT+CGACT=1,1

11:39:06.118 -> AT+CGATT=1,1

11:39:06.118 ->

11:39:06.118 -> +CME ERROR: 58

11:39:06.118 ->

11:39:11.629 -> Command: AT+HTTPINIT

11:39:11.629 -> AT+HTTPINIT

11:38:49.444 ->
11:39:11.629 -> Command: AT+HTTPINIT
11:39:11.629 -> AT+HTTPINIT
11:39:11.671 ->
11:39:11.671 -> CME ERROR 58
11:39:11.671 ->
11:39:17.198 -> Command: AT+HTTPPARA="CID",1
11:39:17.198 -> AT+HTTPPARA="CID",1
11:39:17.198 ->
11:39:17.198 -> +CME ERROR: 58
and just getting CME ERROR 58

Please... You dig deeper in the system documentation. I'm at the end of the road.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.