Go Down

Topic: Have working code. SMS would initally send, but now it doesn't. (Read 1 time) previous topic - next topic

nick_b

Hello,

I am working on a school project that involves using the arduino to send sms messages via a gsm module. I am currently using a SIM900 board with its set of libraries (http://wiki.iteadstudio.com/SIM900/SIM900A_GSM/GPRS_Minimum_System_Module). This is the code I happened to get working:

#include "SIM900.h"                 //libraries included for module to work

#include <SoftwareSerial.h>

#include "sms.h"

SMSGSM sms;
boolean started=false;             //sets initial condition for gsm module
void setup()
{
  Serial.begin(9600);
  Serial.println("GSM Testing to send SMS");
  if (gsm.begin(9600)){
    Serial.println("\nstatus=READY");  //status that displays if GSM module is active and ready to send sms message
    started=true;
  }                               //sets baud rates for arduino and gsm module
  else Serial.println("\nstatus=IDLE");
 
  if(started){
    if (sms.SendSMS("+1xxxxxxxxxx", "Alert! Child still in seat!"))//sends text message alert to specified phone number
    Serial.println("\nSMS sent OK"); //status that displays once sms message was successfully sent
  }
};
void loop()
{
};

This code would send sms to my phone. But when I tried to get the GSM module to turn itself on and off using digitalwrite commands, I was no longer receiving messages from the gsm, even though the serial monitor said that the message had sent. I was wondering if trying to make the board turn itself on and off caused this problem and whether or not it could be fixed or if I would need to get a new board. Any feedback would be much appreciated.

Thank You

LMI1

If you put your SIM card from the shield into a phone does it work?


dannable

When you upload that code to the Arduino does it still work?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

nick_b

When I upload it to the arduino, the code runs normally and the serial monitor says that an sms was sent but nothing happens.

dannable

Try the 'send' code in the link in my signature and see if you have any more success with that. If not, try the SerialRelay instructions.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

nick_b

I already have a code that runs on AT commands and I've been using that to try to see what the problem is.



#include <SoftwareSerial.h>

SoftwareSerial mySerial(50, 51);

void setup()
{
  mySerial.begin(9600);   // Setting the baud rate of GSM Module 
  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)
  delay(100);
  SendMessage();
}

void loop()

 if (mySerial.available())
 Serial.write(mySerial.read());
}


 void SendMessage()
{
  mySerial.println("AT+CMGF=1""\r");    //Sets the GSM Module in Text Mode
  delay(500);
  mySerial.println("AT+CMGS=\"+1xxxxxxxxxx\""); // Replace x with mobile number
  delay(3000);
  mySerial.println("Alert!");// The SMS text you want to send
  delay(1000);
  mySerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
  mySerial.print("AT+CMGDA=\"DEL SENT\"");
  mySerial.println();
  delay(500); 
}

This is the serial response I get

AT+CMGF=1


OK
AT+CMGS="+1xxxxxxxxxx"

> Alert!

>
+CMGS: 108

OK


Based on my observation, it looks like the SIM900 isn't responding to the ctrl+z command and staying in text entry mode until it resets. Would this be a problem with my code or the board itself?


dannable

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

nick_b


dannable

Take a simple SerialRelay program, scan the input from the Serial Monitor checking for a particular character (say carat, '^'). If you receive that character send write(char(26)), otherwise relay the character. Make sure Echo is on so it will repeat your instructions back to the monitor. Then go through the AT commands to send an SMS and see what response you get.

If it replies 'OK' then I'm erring towards a service provider issue.

You have obscured your number - I'm assuming you are in the US?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield


nick_b

Also I thought about what you said regarding service provider issues, so I switched the t-mobile sim card for an at&t sim card and the serial monitor still outputs the same response but this time the message goes through.

dannable

Which demonstrates that there is no problem with the code or hardware, but there is one with t-mobile?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

nick_b

Yes. It appears that both sets of codes work fine. It's just a matter of whether or not the inserted sim card is able to connect to the network. (I found out that my t-mobile account had no money so it wasn't able to send sms even though the sim card could connect with the network.)

LMI1

Yes. It appears that both sets of codes work fine. It's just a matter of whether or not the inserted sim card is able to connect to the network. (I found out that my t-mobile account had no money so it wasn't able to send sms even though the sim card could connect with the network.)
That is why it helps to test the sim card in the phone.

But it is good to hear that you have solved the problem.

Go Up