Jump to content
43oh

Interfacing msp430g2553 with gsm sim900


Recommended Posts

Hello,

I am using msp430g2553 mcu and I interfaced that mcu with gsm sim900 successfully. Now I am facing some strange behavior in the code.

When I write the loop as follows:

void loop()
{
  String buffer = readSIM900A();
  String msgOn = buffer;
  String number1 = "8320389582"; //problem
  String number2 = "9106555707"; //problem
  String number3 = "9979933498"; //problem

    if (buffer.startsWith("\r\n+CMT: "))
    {
         Serial.println(buffer);
           buffer.remove(0,12);
           buffer.remove(10);
           Serial.println(buffer);
           msgOn.remove(0,51);
           msgOn.remove(3);
           Serial.println(msgOn);   
       if(((buffer==number1)||(buffer==number2)||(buffer==number3))&&((msgOn=="On")||(msgOn=="ON")||(msgOn=="on")))
       {
            digitalWrite(led, HIGH);
        }

 

    }

    delay(100);

 
}

In the lines above commented with "problem":

-> When I write String number1 = "8320389582"; //problem like this and when I use this for toggling led like this

if(((buffer==number1)||(buffer==number2)||(buffer==number3))&&((msgOn=="On")||(msgOn=="ON")||(msgOn=="on")))
       {
            digitalWrite(led, HIGH);
        }

This doesnt work but instead when I use the code like

if(((buffer=="+91963xxxx")||(buffer=="+91963XXXX")||(buffer=="+918753XXX"))&&((msgOn=="On")||(msgOn=="ON")||(msgOn=="on")))
       {
            digitalWrite(led, HIGH);
        }

This works and I can toggle the led.

According to my understanding there is some compiler issue in this related to memory for local loop.

Can anyone help me with this?

I am attaching my code for reference.

Thanks,

Shailav

 

 

 

 

prefinal.rar

Link to post
Share on other sites

Be very carful with the String library on small RAM devices like to G2553. The G2553 only has 1/2 a KB of RAM and you are most likely running out of RAM. I would avoid using the String library all together on the G2553. However you can try the following:

  1. Make number1 ,2 and 3 a global by declaring them outside the setup and loop and make them of type char.
  2. avoid the msgOn = buffer statement in the loop.
  3. If you know what the maximum string size is readSIM900A can ever return then declare buffer with String buffer[MAX_SIZE] as a global and then in the loop do buffer = readSIM900A().

This might just free up enough memory to make this work but you will most likely run into trouble again if you continue using the String library.

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...