GSM.begin hangs

Hi,

I have a problem with the GSM.begin function about 50% of the time it hangs. I have a electric sheep (atmega 2560) from sparkfun with the gsmshield on top. I feed it 12V 1A externally.

It appears if the communication with the GSM just stops most of the time. On a few occasions I see a few garbage bytes over the serial line.

I have included a snippet of the code where I added a small delay and almost stock example code. I have also included a successfull and a failed start attempt. Does this problem sound familiar?

boolean notConnected = true;
  for(byte i=0; i< 5; i++)
  {
    Serial.println(i, DEC);
    delay(1000);
  }
  while(notConnected)
  {
    if(gsmAccess.begin(PINNUMBER)==GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      //wdt_reset(); // Reset the WDT
      delay(1000);
    }
  }

Success

AT%13%
0 9>AT%13%%13%%10%OK%13%%10%                                                 
AT+CPIN=7130%13%                                                              
9 44>AT+CPIN=7130%13%%13%%10%+CPIN: READY%13%%10%%13%%10%OK%13%%10%           
AT+CGREG?%13%                                                                
44 75>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%             
AT+CGREG?%13%                                                                
75 120>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%%13%%10%Call Ready%13%%10%                                                                   
AT+CGREG?%13%                                                                
120 23>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%             
AT+CGREG?%13%                                                                
23 54>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%             
AT+CGREG?%13%                                                                 
54 85>AT+CGREG?%13%%13%%10%+CGREG: 0,1%13%%10%%13%%10%OK%13%%10%              
AT+IFC=1,1%13%                                                               
85 102>AT+IFC=1,1%13%%13%%10%OK%13%%10%                                       
AT+CMGF=1%13%                                                                 
102 118>AT+CMGF=1%13%%13%%10%OK%13%%10%                                      
AT+CLIP=1%13%                                                                
118 6>AT+CLIP=1%13%%13%%10%OK%13%%10%                                        
ATE0%13%                                                                   
6 17>ATE0%13%%13%%10%OK%13%%10%                                              
AT+COLP=1%13%                                                               
17 23>%13%%10%OK%13%%10%                                                     
GSM initialized                                                             
Number: +316********                                                         
Message:                                                                    
Arduino test SMS                                                              
AT+CMGS="+316********"%13%                                                   
23 27>%13%%10%>                                                            
Arduino test SMS%26%%13%                                                     
23 46>%13%%10%> %13%%10%+CMGS: 11%13%%10%%13%%10%OK%13%%10%                  
Send 16bytes Return endSMS()1                                                                             
 COMPLETE!

Fail

AT%13%                                                                                                     
0 9>AT%13%%13%%10%OK%13%%10%                                                                              
AT+CPIN=7130%13%                                                                                          
9 44>AT+CPIN=7130%13%%13%%10%+CPIN: READY%13%%10%%13%%10%OK%13%%10%                                       
AT+CGREG?%13%                                                                                              
44 75>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%                                           
AT+CGREG?%13%

I looked into the library and added a debug message which I see on my screen. It seems that the modem never returns ready. Is this a very save way to code it this way? since it can easily lead to infinite loops.

// Begin
// Restart or start the modem
// May be synchronous
GSM3_NetworkStatus_t GSM3ShieldV1AccessProvider::begin(char* pin, bool restart, bool synchronous)
{	
	pinMode(__RESETPIN__, OUTPUT);

	// If asked for modem restart, restart
	if (restart) 
		HWrestart();
	else 
 		HWstart();
  
	theGSM3ShieldV1ModemCore.gss.begin(9600);
	// Launch modem configuration commands
	ModemConfiguration(pin);
	// If synchronous, wait till ModemConfiguration is over
	if(synchronous)
	{
		// if we shorten this delay, the command fails
		while(ready()==0)
		{
			delay(1000);
			Serial.println("gsm.begin() waiting for ready");
		}			
	}
	return getStatus();
}

The problem is similar to one that occurred because a lack of electrical power to register on the GSM network. Can you confirm that modem continues on?

I think it was a power issue. The electric sheep claimed 1.5A which should be sufficient.

I am working the last week with our own PCB design and I have not seen this problem. So problem solved I guess.

%13% est affiché dans la méthode GSM3ShieldV1ModemCore::writePGM

if (CR)
print("\r"); --> affiche %13%