"cellphone" shield?

Right O.
I have spent the whole weekend trying to get this running smoothly.
Now I need help.

I have a SM5100B on the Sparkfun Shield.

I can get it to send ONE text SMS fine each time it restarts then it fails of ages (like 5 to 10 min), with +CME ERROR:4.

After a while it will send one message again.

I have tried two ways to send, both do the same.
What is missing?? It has got to be something like that.

PLEASE help, Im ready to chuck it in. :frowning:
Here is my code, two examples listed..

Thanks.. M

// Define messenger function
void messageCompleted() {
  // This loop will echo each element of the message separately
  while ( message.available() ) {
    if ( message.checkString("OK") )
             {
             digitalWrite (ReadyLed, HIGH);
             digitalWrite (BusyLed, LOW);
             Serial.println("GSM Ready - OK");
             }
    if ( message.checkString("+CME ERROR: 4") )
             {
             Serial.println(string); // Echo the string
             Serial.println("+CME ERROR:4 -operation not supported. ");
             digitalWrite (ReadyLed, HIGH);
             digitalWrite (BusyLed, HIGH);
             }      
    if ( message.checkString("+SIND: 4") ) 
            {  
            Serial.println("SIM Ready");
            bootOneTime();
            } 
    
    message.copyString(string,MAXSIZE);
    Serial.print(string); // Echo the string
    Serial.println(); // Terminate the message with a carriage return   
  }
  
  
}

void sendSMSpreamble() {
    delay(1500);
    cell.print("at+cmgs=");  // comand message
    cell.print(34,BYTE);     // "
    cell.print(PHONE);       // Insert phone number
    cell.println(34,BYTE);   // "
    Serial.println("preamble");
    delay(1500);
}

void sendSMSappend() {
    delay(500);
    cell.println(26,BYTE);                // end of message command Ctrl-z
    Serial.println("append");
    delay(5000);
    isActive0 = 0;    //Finished Sending
}

void sendErrorSMS() {
    sendSMSpreamble();
    Serial.print("Error: ");
   // cell.print(errorMsg[error]);
   // writeStatus();
    sendSMSappend();
}  

void StatCheckGSM() {
  cell.println("atz");
  delay(1000);
}

void sendTestSMS() {
  SetMode();
  sendSMSpreamble();
  sendStatus();
  sendSMSappend();
}

void sendStatus() {
  cell.print("Test SMS: ");
  cell.println(SMS0);
  Serial.println("message");
}

void sendStatusSMS() {
  sendSMSpreamble();
  //writeStatus();
  sendSMSappend();
}

void SetMode() {
  cell.println("at+cmgf=1");  //Set message mode to Text (1)
  Serial.println("setmode");
}


void bootOneTime() {
    digitalWrite (ReadyLed, LOW);
    digitalWrite (BusyLed, HIGH);
    cell.println("at+cmgf=1");  //Set message mode to Text (1)
    delay(1000);
    cell.println("AT+CSQ");  // Check signal strength
    Serial.println("System Ready...."); 
    digitalWrite (ReadyLed, HIGH);
    cell.println("AT+CMGD=1,4");
  }

Also Have tried the following.

  // Send the restore SMS
  if ( SMS1 >= 1  && isActive1 == 0 ) {
      Serial.print("Door-1 Restore. Now Closed after "); // Do something only if interval has elapsed and the metro is "active"
      Serial.print(SMS1);
      Serial.println(" times.");
      Door1Metro.interval(timing);
      cell.println("at+cmgf=1");
      Serial.println("at+cmgf=1");
      delay (100);
      cell.print("at+cmgs=");
      Serial.println("at+cmgs=");
      cell.print(34,BYTE);
      cell.print(PHONE);
      Serial.println(PHONE);
      cell.println(34,BYTE);
      //cell.print(13,BYTE);
      cell.print("Door 1 Restore. Door 1 Now secure. Door trigger was looped ");
      cell.print(SMS1);
      cell.print(" times.");
      cell.println(26,BYTE);
      cell.print("ok");
      SMS1 = 0;
    }


//cell.println("at+cmgf=1");
//cell.print("at+cmgs=");
//cell.print(34,BYTE);
//cell.print(PHONE);
//cell.println(34,BYTE);
//cell.print("Your Message Here");
//cell.print(SMS1); //insert counter
//cell.println(26,BYTE);