GSM Sleep? Can your modem sleep?

Hi there,

I have an Uno, coupled with an Arduino GSM shield. I'm using the SerialGSM.H library to send sms signals anytime I detect a change from no light to light.

The problem: I'm trying to save power by only booting up the GSM modem and turning it on when a condition is true.

The issue: everytime I try to boot up the gsm when the condition is triggered, it sends a text but then goes on a weird recursive loop and never starts executing the rest of the code. It's like it starts to boot again and again and again, likely because I have the booting in the LOOP and not the setup.

void setup(){
 pinMode(ledPin, OUTPUT);  // Set lepPin - 13 pin as an output
 pinMode(pResistor, INPUT);// Set pResistor - A0 pin as an input
 pinMode(pirSensor, INPUT);// Set pirSensor - 12 pin as an input 
 Serial.begin(9600); //start recording serial 
 cell.begin(9600); //start recording cell serial 
 cell.Verbose(true);
}

boolean shouldDialMyself=true;
boolean shouldSendSMS=true; 
void loop(){
  value = analogRead(pResistor); 
  val = digitalRead(pirSensor); 
  touchSensorValue = analogRead(sensorPin);
  boolean isSafeOpen = value > 250;
  Serial.println(touchSensorValue);
  boolean touchID = touchSensorValue <500;
  
  //You can change value "25"
  if (isDoorOpen || val==HIGH){
    cell.Boot(); 
    cell.FwdSMS2Serial();
    Serial.println(isSafeOpen); 
    Serial.println(value); 
    Serial.println(val); // print the pir value 
    //tone(pzo, 1000,5);
    digitalWrite(ledPin, HIGH);  //Turn led on  
    if (shouldSendSMS) {
      cell.Rcpt("+123");
      cell.Message("someone stealing food!");
      cell.SendSMS(); 
      cell.EndSMS();
      shouldSendSMS = false;
    }
  } else if (!isDoorOpen || val==LOW){
    digitalWrite(ledPin, LOW); //Turn led off
    shouldSendSMS=true;
    pirState=LOW; //setting the PIR sensor back to low 
    Serial.println(value); }

any help is greatly appreciated on how to boot up, and turn off, the GSM modem and essentially only use it when I need it. As you can see above I have cell.Boot(); in the loop. Previously, it was in the setup and it works fine but draws tons of power (batteries last like an hour)