Go Down

Topic: Delete sms from sim900 (Read 927 times) previous topic - next topic

ehsan8888

I try with below project to remote control  main contactor of a system with sms and receive feedback  from main contactor action with below program; I can send sms to sim900 module ;for example when I send sms  "MAIN CONTACTOR ON" to sim900 pin output MAIN will be high and sim900 after receive feedback (digitalRead(9)==HIGH) will send sms to mentioned numbers and in the end of viod loop I try to delete all sms from sim card whit:  sms.DeleteSMS((int)pos);
But whit start viod loop again pin output MAIN will be high again (the opposite of desire). and because of feedback existence (digitalRead(9)==HIGH) sim900 will send sms to mentioned numbers again (the opposite of desire).
Therefore I will have send sms by sim900 because of feedback existence (digitalRead(9)==HIGH) every cycle (over and over) the opposite of desire .
Please give your proper advice to rectify this problem.

void loop(){
 pos=sms.IsSMSPresent(SMS_UNREAD);
  Serial.println((int)pos);
  if((int)pos>0&&(int)pos<=20){
   Serial.print("NUOVO MESSAGGIO, POS=");
   Serial.println((int)pos);
   message[0]='\0';
    sms.GetSMS((int)pos,number,message,180);
   }
      p=strstr(message,"MAIN CONTACTOR ON");   
  if(p){   
    digitalWrite(MAIN,HIGH);     
    if(digitalRead(9)==HIGH){
       if (sms.SendSMS("09137841587", "System on"))
       if (sms.SendSMS("09137841712", "System on"))
       Serial.println("\nSMS sent OK");
      }
      }   
p=strstr(message," MAIN CONTACTOR OFF");   
  if(p){
    digitalWrite(MAIN,LOW);
    if(digitalRead(9)==LOW){
       if (sms.SendSMS("09137841587", "System off"))
       if (sms.SendSMS("09137841712", "System off"))
       Serial.println("\nSMS sent OK");
       }
       }
      sms.DeleteSMS((int)pos);
       }

Go Up