Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Error send sms sim900

Status
Not open for further replies.

Manoela Brum

Newbie level 2
Joined
May 6, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,348
Please help me!

I need to send a sms from module at900 for a mobile cell and is returning the error ps busy (if cmee=2) or the error 515 (if cmee=1) when I print the CMGS="number" command.

I know:

'CMS ERROR 515' is received in the following cases:
1. Sending an SMS message when the SIM initialization is going on (after rebooting the module).
2. Reading a SMS immediately after booting the module when the SIM initialization is not over yet.
3. Write a SMS to memory before SIM initialization is complete.
4. Sending more than one SMS at one time or send a SMS when the response (OK or ERROR) for a previously sent SMS has not been received.

Neither of the cases above is the mine, because my preferred storage is empty and there isn't neither command in wait and my module is initialized.

I'm using the following codes:

//First code:

#include <SoftwareSerial.h>
#include <String.h>

SoftwareSerial mySerial(2,3);

#define BUF_LEN 84

int statuspin = 4;
int pinState = 0;
int x,y,i,j;
char ncadastrado[] = "555412345678";
char nremetente[] = "";

char codcadastrado[] = "0001";
char codremetente[] = "";

const int MAXDATA1 = 256;
const int MAXDATA2= 256;
char msg1[MAXDATA1];
char msg2[MAXDATA2];

const int MAXDATA = 256;
char data [MAXDATA];



byte num_of_bytes;
byte retorno;
char comm_buf[256];
byte n;


void setup(){

mySerial.begin(19200); // the GPRS baud rate
Serial.begin(19200); // the GPRS baud rate

mySerial.println("AT+CIFSR");//executa comando
delay(3000); //espera resultado na serial
leserial(); //processa dados e armazena no buffer
retorno = IsStringReceived("OK"); // verifica se o retorno é o esperado
Serial.println(comm_buf); //mostra retorno real
limpa_buffer(); //limpa buffer

mySerial.println("AT+CSQ");//executa comando
delay(3000); //espera resultado na serial
leserial(); //processa dados e armazena no buffer
retorno = IsStringReceived("OK"); // verifica se o retorno é o esperado
Serial.println(comm_buf); //mostra retorno real
limpa_buffer();

mySerial.println("at+cstt=\"zap.vivo.com.br\",\"vivo\",\"vivo\"");//executa comando
delay(2000); //espera
leserial(); //processa dados e armazena no buffer
retorno = IsStringReceived("OK"); // verifica se o retorno é o esperado
Serial.println(comm_buf); //mostra retorno real
limpa_buffer();

mySerial.println("at+ciicr");//executa comando
delay(5000); //espera resultado na serial
leserial(); //processa dados e armazena no buffer
Serial.println(comm_buf); //mostra retorno real
limpa_buffer();

mySerial.println("at+cifsr");//executa comando
delay(2000); //espera resultado na serial
leserial(); //processa dados e armazena no buffer
retorno = IsStringReceived("OK"); // verifica se o retorno é o esperado
Serial.println(comm_buf); //mostra retorno real
limpa_buffer();

mySerial.println("at+cdnscfg?");//executa comando
delay(2000); //espera resultado na serial
leserial(); //processa dados e armazena no buffer
Serial.println(comm_buf); //mostra retorno real
limpa_buffer();

mySerial.println("AT+CMGF=1\r"); // Because we want to send the SMS in text mode
delay(1000);
mySerial.println("AT+CMGS=\"555412345678\"\r"); // Setting for the SMS Message center number,
delay(1000);
leserial();
Serial.println(comm_buf); //mostra retorno real
limpa_buffer();

mySerial.println("mensagem de teste"); // Start accepting the text for the message
delay(1000);
mySerial.println((char)26);
leserial();
Serial.println(comm_buf); //mostra retorno real
limpa_buffer();
}

byte IsStringReceived(char const *compare_string)
{
//Serial.println("testando...");
char *ch;
byte ret_val = 0;

if(1) {
ch = strstr((char *)comm_buf, compare_string);
if (ch != NULL)
{
Serial.println("existe Valor");
ret_val = 1;
}
else
{
}
}
return (ret_val);
}

void limpa_buffer()
{
memset(comm_buf,'\0',BUF_LEN);
}

void leserial()
{
num_of_bytes = mySerial.available(); //Pega quantidade de bytes que estao na serial
while (mySerial.available() > 0) //Espera de até Available ser true
{
for(n=0; n<num_of_bytes; n++)
{
comm_buf[n] = mySerial.read(); //armazena buffer e a cada mySerial.read carry on buffer interno
}
}
mySerial.flush(); //limpa buffer de entrada da serial
}

void loop(){}


//Second code:

#include <SoftwareSerial.h>
#include <String.h>
SoftwareSerial mySerial(2, 3);
void setup()
{
mySerial.begin(19200); // the GPRS baud rate
Serial.begin(19200); // the GPRS baud rate
delay(500);
}
void loop()
{
if (Serial.available())
switch(Serial.read())
{
case 't':
SendTextMessage();
break;
case 'd':
DialVoiceCall();
break;
case 'h':
SubmitHttpRequest();
break;
case 's':
Send2Pachube();
break;
}
if (mySerial.available())
Serial.write(mySerial.read());
}
///SendTextMessage()
///this function is to send a sms message
void SendTextMessage()
{
mySerial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
delay(100);
mySerial.println("AT + CMGS = \"555412345678\"");//send sms message, be careful need to add a country code before the cellphone number
delay(100);
mySerial.println("A test message!");//the content of the message
delay(100);
mySerial.println((char)26);//the ASCII code of the ctrl+z is 26
delay(100);
mySerial.println();
}
void ShowSerialData()
{
while(mySerial.available()!=0)
Serial.write(mySerial.read());
}
//the others functions aren't importants.

ALL the codes return the same error: ps busy.
If I use the SoftwareSerialExample code, for print the at commands directly for the module, returns the same error: ps busy.
I try with different hyperterminals and is the same error.
If I use the library for send the message, the dispatch is ok, but I need get send without the library, only with the at commands.

Why is returning this error? What I can do for fix them?


Please help me!

Thank you!

:)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top