Cant establish a gprs connection

Hi,
i am new to arduino and trying to get my SIM900 running. At this stage I am testing the module using the "AT"-Commands.

The APN is "pinternet.interkom.de"Found here

Edit:
I noticed that the Sim Module is shutting down after about 10 sec. from starting it. It doesnt do this, when i pull the sim card out.
Is this a problem with the SIM card or the code?
My Code:

#include <SoftwareSerial.h>

SoftwareSerial sim900(2, 3);  // RX, TX Pins des SIM900-Moduls

void setup() {
  Serial.begin(9600);
  sim900.begin(19200);
  delay(2000);  // Warte, bis das SIM900-Modul initialisiert ist

  // Überprüfe die Grundfunktionen des SIM900-Moduls
  checkSIM900Ready();
  checkSIMCardStatus();
  checkSignalStrength();
  configureGPRS();  // GPRS-Verbindung konfigurieren
  establishGPRSConnection();
  checkGPRSConnection();
}

void loop() {
  // Deine weiteren Programmlogik hier
}

void checkSIM900Ready() {
  // Überprüfe die Betriebsbereitschaft des SIM900-Moduls
  sim900.println("AT");
  delay(500);

  while (sim900.available()) {
    String response = sim900.readString();
    Serial.print(response);

    // Überprüfe, ob die Antwort "OK" enthält
    if (response.indexOf("OK") != -1) {
      Serial.println("SIM900 ist betriebsbereit");
      return;
    }
  }

  Serial.println("Fehler: SIM900 ist nicht betriebsbereit");
}

void checkSIMCardStatus() {
  // Überprüfe den Status der SIM-Karte
  sim900.println("AT+CPIN?");
  delay(500);

  while (sim900.available()) {
    String response = sim900.readString();
    Serial.print(response);

    // Überprüfe, ob die Antwort "+CPIN: READY" enthält
    if (response.indexOf("+CPIN: READY") != -1) {
      Serial.println("SIM-Karte ist eingelegt und betriebsbereit");
      return;
    }
  }

  Serial.println("Fehler: Keine SIM-Karte oder SIM-Karte nicht betriebsbereit");
}

void checkSignalStrength() {
  // Überprüfe die Signalstärke
  sim900.println("AT+CSQ");
  delay(500);

  while (sim900.available()) {
    String response = sim900.readString();
    Serial.print(response);

    // Überprüfe, ob die Antwort "+CSQ:" enthält
    if (response.indexOf("+CSQ:") != -1) {
      Serial.println("Signalstärke wurde erfolgreich abgerufen");
      return;
    }
  }

  Serial.println("Fehler: Signalstärke konnte nicht abgerufen werden");
}
void configureGPRS() {
  // Konfiguriere die APN-Einstellungen für die GPRS-Verbindung
  sim900.println("AT+SAPBR=3,1,\"Contype\",\"GPRS\"");
  delay(500);
  sim900.println("AT+SAPBR=3,1,\"APN\",\"pinternet.interkom.de\"");
  delay(500);
  sim900.println("AT+SAPBR=1,1");
  delay(500);
}

void checkGPRSConnection() {
  // Überprüfe die GPRS-Verbindung
  sim900.println("AT+SAPBR=2,1");
  delay(500);

  while (sim900.available()) {
    String response = sim900.readString();
    Serial.print(response);

    // Überprüfe, ob die Antwort "+SAPBR: 1,1" enthält
    if (response.indexOf("+SAPBR: 1,1") != -1) {
      Serial.println("GPRS-Verbindung besteht");
      return;
    }
  }

  Serial.println("Fehler: GPRS-Verbindung konnte nicht hergestellt werden");
}
void establishGPRSConnection() {
  // Überprüfe die GPRS-Verbindung
  sim900.println("AT+CGATT?");
  delay(500);

  while (sim900.available()) {
    String response = sim900.readString();
    Serial.print(response);

    // Überprüfe, ob die Antwort "+CGATT: 1" enthält
    if (response.indexOf("+CGATT: 1") != -1) {
      Serial.println("GPRS-Verbindung besteht");
      return;
    }
  }

  Serial.println("Fehler: GPRS-Verbindung konnte nicht hergestellt werden");
}

The Response i get is

20:52:18.107 -> AT
20:52:18.107 ->
20:52:18.107 -> OK
20:52:18.107 -> SIM900 ist betriebsbereit
20:52:19.675 -> AT+CPIN?
20:52:19.675 ->
20:52:19.675 -> +CPIN: READY
20:52:19.675 ->
20:52:19.675 -> OK
20:52:19.721 -> SIM-Karte ist eingelegt und betriebsbereit
20:52:21.205 -> Signalstärke wurde erfolgreich abgerufen
20:52:24.276 -> AT+SAPBR=3,1,"Contype","GPRS"
20:52:24.276 ->
20:52:24.309 -> OK
20:52:24.309 -> AT+SAPBR=3,1,"APN","pinterFehler: GPRS-Verbindung konnte nicht hergestellt werden
20:52:25.848 -> AT+SAPBR=2,1
20:52:25.848 ->
20:52:25.848 -> +SAPBR: 1,3,"0.0.0.0"
20:52:25.881 ->
20:52:25.881 -> OK
20:52:25.881 -> Fehler: GPRS-Verbindung konnte nicht hergestellt werden

I tried the SIM Card in my mobile and it works without a PIN an can establish a connection to the internet.

What is the problem. Does anyone have any ideas?

Thank you all in advance.

Simon

Are you sure it's using GPRS?

Maybe the SIM isn't provisioned for GPRS?

Is there GPRS service at your location?

Note that many networks are phasing-out (sunsetting) 2G & 3G:

Have you tried just issuing the AT commands manually, and seeing what responses you get?

Try AT+CMEE=1 to enable extended error codes

Check SIMCOM documentation for other hints & tips.

Hi Awneil,

thank for your help.

Is there GPRS service at your location?

I didn't thought if i am using g2 oder 3 or 4 in my mobile, so i checked it now. I set the settings to "g2 only" and it could establish a connection. So this isnt the problem. But thanks anyway. wasnt aware of this.

Have you tried just issuing the AT commands manually, and seeing what responses you get?

No, but i try it later.

Try AT+CMEE=1 to enable extended error codes

I added the AT+CMEE=1 command but the responses are the same.

I noticed that the Sim Module is shutting down after about 10 sec. from starting it. It doesnt do this, when i pull the sim card out.
Is this a problem with the SIM card or the code?

Thx.

Remember that all radio modules take large amounts of current when transmitting, and this tends to be very "peaky".
GSM/GPRS can take peaks of several amps.

A very common problem is that your power supply is not "strong" enough to cope with these peaks, so the voltage drops - and the module can't work.

It's quite possible that the 10s is when the module first tries to transmit...

With no SIM, the module would never try to transmit

Thx a lot. It was the power supply. I found a 1 amp power supply at home and it works.

1 Like

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