MKR GSM 1400 sms.read doesnt work

Hello,

I got another MKR GSM 1400 and after a while of not knowing what to do with it I just wanted to read some SMS and look for some bit of text in the SMS.
The problem is that instead of returning the message as my last 1400 did it returns:

+CMGL: 1,"REC UNREAD","MyNumber",,"

The code to read the SMS is this:

    while ((c = sms.read()) != -1)
    {
      Serial.print((char)c);
      SMSBuffer[CharIndex] = (char)c;
      CharIndex++;
      SMSBuffer[CharIndex] = '\0';
    }

I tried loading the Example ReceiveSMS but got the same output.
What is happening?

what does this example loop show when you send an SMS?

void loop() 
{
  char c;

  // If there are any SMSs available()  
  if (sms.available())
  {
    Serial.println("Message received from:");

    // Get remote number
    sms.remoteNumber(remoteNumber, 20);
    Serial.println(remoteNumber);

    // This is just an example of message disposal    
    // Messages starting with # should be discarded
    if(sms.peek()=='#')
    {
      Serial.println("Discarded SMS");
      sms.flush();
    }

    // Read message bytes and print them
    while(c=sms.read())
      Serial.print(c);

    Serial.println("\nEND OF MESSAGE");

    // delete message from modem memory
    sms.flush();
    Serial.println("MESSAGE DELETED");
  }
  delay(100);
}

13:54:43.171 -> GSM initialized
13:54:43.172 -> Waiting for messages
13:54:43.172 -> Message received from:
13:54:43.888 -> +MyNumber
13:54:43.888 -> +CMGL: 2,"REC UNREAD","+MyNumber",,"��������������������������������������������������������...

The � never stop.

if you send a '#' what do you see?

yes for the unlimited �, should be

 while ((c = sms.read()) != -1) {
      Serial.print((char)c);
    }

15:42:24.327 -> GSM initialized
15:42:37.913 -> Waiting for messages
15:42:37.918 -> Message received from:
15:42:46.460 -> +MyNumber
15:42:46.460 -> +CMGL: 5,"REC UNREAD","+MyNumber",,"�������������������������������...

+CMGL: now has a 5 instead of a 2

is that the full example you use?

Yes

SMS buffer full on SIM card?

I put the SIM card into an old Nokia but there were no SMS I could read.
When i send a SMS to the Nokia I could read it in plain text.

weird. Do you have another SIM card you could test with?

try printing the HEX codes instead of the characters

 while ((c = sms.read()) != -1) {
      Serial.print((byte)c, HEX); Serial.write(' ');
    }

Do a downgrade of the board core to 1.8.9. The sms read sketch doesn't work with 1.8.11. There is a bug in communication with MODEM in 1.8.11

I'm unsure what you mean, I tried using multiple IDE versions if you mean that. from 1.8.8 to 2.0 beta

I got this:
2b 43 4d 47 4c 3a 20 37 2c 22 52 45 43 20 55 4e 52 45 41 44 22 2c 22 2b 4d 79 4e 75 6d 62 65 72 22 2c 2c 22
edit it a bit because of my number

Never mind i found it.
https://www.arduino.cc/en/guide/cores
This fixed the Issue, just had to use other words in my google search

In the IDE : Tools-->Board--->Boards Manager-->Arduino SAMD21 --Choose Version 1.8.9
PS: It takes a while to change the core, don't interupt

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.