GSM shield takes a lot of time


I am writing to you because I can't find where the problem is. I explain, I want to send data from an Arduino Mega 2560 to a server. I'm using the Arduino GSM shield v2 with integrated antenna. The problem is that it takes a lot of time to connect to the GSM network and to the GPRS network.
I am trying to use the example "GSMWebClient" from the GSM library. The program gets stuck when the shield try to connect to the GSM network, at this line :


I success to connect only around one time overs twenty. The pin code is correct as well as the apn. With my phone, I can reach network easily and I capture 4G.
I put a wire between pin 2 and 10, like said in the documentation for using the GSM shield with an Arduino Mega, I tried to change the power supply.

I don't know what to do next, I have no idea at all.

Do you have any answers to give me please ?

Thanks for your reading !

On this topic, they also advise to bend the male header attached to pin 2 on the GSM shield to the side so it does not connect to the Mega.

Did you also tried this kind of sketch:

#include <SoftwareSerial.h>
SoftwareSerial gprs(10, 3);

void setup()

void loop()
  if (gprs.available()) Serial.write(;
  if (Serial.available()) gprs.write(;

and send the AT commands on the serial console

OK  // The module is responding

AT+CPIN?  //Check CPIN
+CPIN: READY    // SIM card is unlocked
+CPIN: SIM PIN  // PIN number is required

AT+CPIN="XXXX"   // if PIN is required (replace XXXX by your number)

AT+CGATT?  // Check the module is attached to the network

AT+CIPSHUT // Destroy PDP context

AT+CSTT="apn","user","password"  // Create PDP context with your provider

AT+CIICR  // Bring up the GPRS connection

AT+CIFSR // Get your IP