Go Down

Topic: Sending SMS with Sony Ericsson T610 (Read 1 time) previous topic - next topic

alex72

Jul 08, 2012, 09:13 pm Last Edit: Jul 10, 2012, 02:41 pm by alex72 Reason: 1
Hi all!

I'm trying to get my SE T610 works with arduino to be able to send SMS. After check that sms plain text mode is supported

AT+CMGF=?
0,1

AT+CMGF=1
OK

I'm trying this code:

Quote

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

String send_command(String at_cmd, int dly){

 String msg;
 int incomingByte;

 Serial.println(at_cmd);
 delay(dly);
 while (Serial.available() > 0)
 {
   incomingByte = (Serial.read());
   msg = msg + char(incomingByte);
 }  
 delay(1000);

 return msg;
}


void setup() {
 lcd.begin(16, 4);

 Serial.begin(9600);

 String ret;
 ret = send_command("AT+CMGF=1",3000);
 lcd.clear();
 lcd.println(ret);  
 delay(3000);

 Serial.print("AT+CMGS=\"XXXXXXXXXX\"\r");
 Serial.print("Hello");
 Serial.print(0X1A);

 lcd.clear();
 lcd.println(ret);  
 delay(3000);
}

void loop() {
}



And geta bad "ERROR"...  :0 I've looked to http://www.timzaman.nl/?p=47&lang=en to try with PDU mode instead bu without any success too...

Someone have any idea about my problem? or get T610 working? I've tried international phone number like +33XXXXXXX but no more results..

Thanks,
Alex.

camolas




Code: [Select]

#include <SoftwareSerial.h>// serial speed to use with phone
SoftwareSerial m32_serial(2, 3); // Order is input pin, output pin
#define PHONE_SERIAL_BUAD 9600
// Puts teh phone into SMS texting mode ( as opposed to MMS, etc.)
#define PHONE_SET_SMS_TXT_MODE_COMMAND "AT+CMGF=1"
// Command used to send a message
#define PHONE_SEND_MSG "AT+CMGS="
// Command to dial a call
#define PHONE_DIAL_CALL "ATD"
#define PHONE_END_CALL "ATH"
#define BUFFSIZ 90 // plenty big
#define ARDUINORX 2
#define ARDUINOTX 3

char buffer[BUFFSIZ];
char buffidx;
//***
char r=13;  //return character
String cellContent="";   //string we're sending
String ctlZ="\x1A";     //the code for Ctrl-Z
String content="SMS messaage";    //The text I'm sending
//***


void setup()
{
Serial.begin(9600);
Serial.println("Hello PC");

// set the data rate for the modem port
m32_serial.begin(PHONE_SERIAL_BUAD);
delay(1000);
m32_serial.println("AT");wait4OK();
delay(600);
m32_serial.println("AT");wait4OK();
ATTest();



}


void loop() // run over and over again
{
  cellContent+=content;
  cellContent+=ctlZ;
  m32_serial.print("AT+CMGF=1");
  delay(600);
  m32_serial.print(r);
  delay(600);
  m32_serial.print("AT+CMGS=\"xxxxxxxxx\""); // number
  delay(600);
  m32_serial.print(r);
  delay(600);
  m32_serial.print("paulos");    //(cellContent);
  delay(600);
m32_serial.print(ctlZ);
delay(600);
  m32_serial.print(r);
 
delay(500);

}

void ATTest(){
Serial.println("Arduino: Test modem Communication..wait..(if >5sec..fail..)");
m32_serial.println("AT");
if (wait4OK()==1) {
Serial.println("Arduino: OK");
}
else{
Serial.println("Arduino: Fail!, please check connection! ");
Serial.print("Connect pin"); Serial.print(ARDUINOTX); Serial.print("to GSM RX, ");Serial.print(ARDUINORX); Serial.print(" to GSM TX");
ATTest();
}
}

int wait4OK() {
int returnVal=0;

GSMreadline();
Serial.print("GSM: ");
Serial.println(buffer);
if (strncmp(buffer, "OK",2) == 0) {
returnVal=1;
} else {
returnVal=-1;
ATTest();
}
return returnVal;
}

void GSMreadline(void) {
char c;

buffidx = 0; // start at begninning
int crCount=0;
while (1) {

c=m32_serial.read();

if (c == -1){
delay(500);
continue;
}
if (c == '\n')
continue;


if((int) c == 13){
crCount++;

if (crCount==1 || crCount==2)
continue;
if (crCount==3){
buffer[buffidx] = 0;
return;
}
}


if (buffidx == BUFFSIZ-1){
buffer[buffidx] = 0;
return;
}
if (crCount==2){
buffer[buffidx++]= c;
}
// buffer[buffidx++]= c; //org
}
Serial.println("END WAIT");
}




Go Up