shailav619

Interfacing msp430g2553 with gsm sim900

4 posts in this topic

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

Share this post


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.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now