Skip to main content
1 of 5
SoreDakeNoKoto
  • 2.4k
  • 2
  • 14
  • 23

You misspelled the variable senderNumber. Correct it. Also you aren't reading the SMS properly or comparing the phone numbers properly. Your code should be like this (using the examples):

MAX_MSG = 50;

char senderNumber[20];
char sms_buf[MAX_MSG];   // a buffer for your sms, max len = 50

if (sms.available()) {    // this part should be in loop()
  sms.remoteNumber(senderNumber, 20);
  if (strcmp(senderNumber, "09432167015") == 0) { // compare numbers
    while (sms.available() == 0);   // wait for a char
    char i = 0;
    while (i < MAX_MSG){    // till max len is reached
      c = sms.read();
      if (c == '\0')  // assuming the modem terminates sms with null
        break;
      sms_buf[i++] = c;   // write char to the buffer
      while (sms.available() == 0);   //wait for a char
    }
  }
  if (strstr(sms_buf, "yes") != NULL)  // look for 'yes' in buffer
    alarm_police();
}
SoreDakeNoKoto
  • 2.4k
  • 2
  • 14
  • 23