Control water pump through sms using a old sony phone interfaced with arduino

void setup() {

Serial.begin(9600);
delay(3000);
Serial.println("AT+CPMS="ME""); // AT commands for sony T610
delay(3000);
Serial.println("ATE=0"); // ECHO off
delay(3000);
Serial.println("AT+CMGF=1"); //text format
delay(3000);
Serial.println("AT+CMGR=1"); //read text message from the location 1 of the phone
delay(3000);

if (Serial.available() > 0) {
/* Now i cant understand how to assign that
data string received in the form of text message to a memory
locaton on arduino and compare with another string and
then do the appropriate action.*/

/* I want to compare the received message with string "ON" and "OFF"
and if the message contains ON then set a digital pin high for 30 minutes max and
if off is received then set that digital pin Low

*/
}

void loop() {

}

testing.pde (869 Bytes)

Embedding your questions in the comments is a good way to get ignored. I'd recommend that you not do that again.

I'd recommend that you learn how to read serial data, how to save it an an array, and how to parse that data, before you worry about what to do with a value received from the phone.

Below is some simple on/off test code Use the # post tool bar to use the code tags.

// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

int ledPin = 13;
String readString;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT); 
  Serial.println("serial on/off test 0021"); // so I can keep track
}

void loop() {

  while (Serial.available()) {
    delay(1);  
    char c = Serial.read();
    readString += c; 
  }

  if (readString.length() >0) {
    Serial.println(readString);

    if (readString == "on")     
    {
      digitalWrite(ledPin, HIGH);
    }
    if (readString == "off")
    {
      digitalWrite(ledPin, LOW);
    }

    readString="";
  } 
}

I make this for control led with serial communication with sony ericsson k700....

//Remote control GSM V 1.0
 
 int ledPin=13;
 String readString; 
 char c; 
 
  void setup() {
  
  pinMode(ledPin,OUTPUT);
  delay(12000);
  Serial.begin(9600);
  delay(3000);
  Serial.println("AT+CPMS=\"ME\",\"SM\"");//Set memory phone
  delay(5000);
  Serial.println("ATE=0");//Echo off
  delay(3000);
  readsms:
  Serial.println("AT+CMGR=1");//Read sms
  delay(5000);
  
}
  
  void loop() {
  
     delay(100);
  
  	// read phone reply if available
	if (Serial.available() > 0) {
  
                c=Serial.read(),BYTE;
                readString+=c;

               Serial.println(readString);
              if (readString.indexOf("96xxxxxxxx")>0 &&(readString.indexOf("34F670C")>0)//admin and pdu "on"
              { 
                 digitalWrite(ledPin,HIGH);
                 goto delsms;                 
              }
              if (readString.indexOf("96xxxxxxxx")>0 &&(readString.indexOf("44FA33106")>0)
              {
                 digitalWrite(ledPin,LOW);
                 goto delsms;
              }
              
	}

  } 
  delsms:
  Serial.println("AT+CMGD=1");//Delete sms
  delay(120000);
  goto readsms;

thanks

i dont understand this ......please clarify...this code line
readString.indexOf("96xxxxxxxx")>0 &&(readString.indexOf("44FA33106")>0)..
may be 96xxxxxxx in the no.
and hex code..... "44fa33106" meant?

okk i got it.....
34F670C meant ON1
and same manner for OFF1..
thanks for the help

hi
please help me..
i used sony ericsson k810i + arduino uno but thats not work..
at commands work with hyper terminal
please help
my code :

//Remote control GSM V 1.0

int ledPin=13;
String readString;
char c;

void delsms(){
Serial.println("AT+CMGD=1");//Delete sms possition 1
}

void setup() {

pinMode(ledPin,OUTPUT);
delay(12000);
Serial.begin(9600);
delay(3000);
Serial.println("AT+CPMS="ME","SM"");//Set memory phone
delay(5000);
Serial.println("ATE=0");//Echo off
delay(3000);
readsms:
Serial.println("AT+CMGR=1");//Read sms
delay(5000);
}
void loop() {

delay(100);

// read phone reply if available
if (Serial.available() > 0) {

c=Serial.read(),BYTE;
readString+=c;

Serial.println(readString);
if (readString.indexOf("9377404499")>0 &&(readString.indexOf("34F670C")>0))//admin and pdu "on"
{
digitalWrite(ledPin,HIGH);
delsms;
}
if (readString.indexOf("9377404499")>0 &&(readString.indexOf("44FA33106")>0))
{
digitalWrite(ledPin,LOW);
delsms;
}

}
}

s2sobhani:
i used sony ericsson k810i + arduino uno but thats not work..

"Not work" doesn't give us any idea what you want it to do or what it's actually doing.

Your sketch seems to be writing AT commands to the hardware serial port, and reading responses from the same port. Usually this port would be used for communication with the PC so that you can see what is going on. Trying to connect more than one device to a given serial port is asking for trouble. How is the Arduino connected to the modem and to the PC?

hi thanks for repply
sony ericsson k810i rx tx is connected to pins 0 and 1..i use pin 13 for output..
i wanna switch pin 13 to ON(with ON1) and OFF (with OFF1)..
every thing work correct but when send sms to k810i nothing heppend..
i tested it with usb power and 12V 1.5A power adaptor
arduinu connected to pc with usb and pins 0 1 connected to k810i but when i wanna send sms i plug out usb..
thanks for help