I wanted to my GSM to recieve SMSs. I have written a sketch for it. But while verifying the sketch an error pops out in this part:

if (sms.available()) { sms.remoteNumber(senderNnumber, 20); if (senderNumber == "09432167015") { c = sms.read(); if (c == "yes") { alarm_police(); } } }

The error message:

Arduino: 1.6.5 (Windows 8.1), Board: "Arduino/Genuino Uno"

GuardDog_v2.5.ino: In function 'void loop()': GuardDog_v2.5:201: error: 'senderNnumber' was not declared in this scope GuardDog_v2.5:204: error: ISO C++ forbids comparison between pointer and >integer [-fpermissive] 'senderNnumber' was not declared in this scope

This report would have more information with "Show verbose output during compilation" enabled in File > Preferences.

I have checked the receiving sms example and have written the sketch according to the example.I need help regarding this error and how to fix it

  • You have a scope problem and you are comparing a pointer to an integer. Show us the rest of your sketch and provide a link to the library u're using Jan 29, 2016 at 14:57
  • The sketch is a bit too big and contains parts which are not related to GSM. Should I show the complete sketch? BTW the library I used is the default GSM library which is present in the IDE.
    – HDatta
    Jan 29, 2016 at 15:22

1 Answer 1


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):

#define 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 - 1){    // till max len is reached; 1 byte for null
      c = sms.read();
      if (c == '\0')  // assuming the modem terminates sms with null
      sms_buf[i++] = c;   // write char to the buffer
      while (sms.available() == 0);   //wait for a char
    sms_buf[i] = 0;   // terminate the string, just in case
    if (strstr(sms_buf, "yes") != NULL)  // look for 'yes' in buffer
  • is MAX_MSG an int
    – HDatta
    Jan 30, 2016 at 7:26
  • It can be a char or int; just edited it Jan 30, 2016 at 11:06
  • during the upload an error for char sms_buf[MAX_MSG]; pops up: array bound is not an integer constant before ']' token.
    – HDatta
    Feb 1, 2016 at 12:40
  • Change MAX_MSG to int and try again Feb 1, 2016 at 13:17
  • I had used int for MAX_MSG it doesn't work for both char and int
    – HDatta
    Feb 2, 2016 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.