Want to know the number of the person who has send me SMS over GSM module

I am using SIM900A based GSM module and doing some stuff related to sending and receiving SMS.What i want to do is to revert back on the same number from where a specific message come.For that i need to know the number of the person from where that SMS come.

what i am doing right now is printing all the information on a 16*2 LCD instead of serial port(though i tried to print all the data which is coming from serial port using software serial and a RS232 but only AT command get printed and nothing else. )

I am using these command to initiate GSM module in text mode and get notification for every arrived new SMS.

Serial.println("AT+CMGF=1");
delay(200);
Serial.println("AT+CSMS=1");
delay(200);
Serial.println("AT+CNMI=2,2,0,0");

is there is any At command which give information regarding from where the last SMS come i.e. its Number so that i can save that number in a variable and revert back on the same number.

Need help.

Look at the CMGR codes. "" means "originating address", meaning the sender's phone number.

http://narobo.com/products/DroneCell/datasheet/ATC.pdf

hi,

yes i had looked in the AT command manual for SIM900A and came to know about AT+CMGR command.I want to ask that what command should i send through serial.println , so that it revert me back with the OA only, or it will always revert me back with all the data, that is described there i.e.

,,....................till .

Because if there is a command which make me get only Originating address , than its a bit easy for me, to revert on the same number, or if i get the whole string, i need to store that string in buffer and then parse it to get the number using strtok function.Am i right?

Also i am facing one more problem that when ever i am sending any message using below code, it is always being delivered in flash message format instead of a simple text message.I don't know where i am messing up.

oid setup()
{
Serial.begin(9600); //Baud rate of the GSM/GPRS Module
Serial.print("\r");
delay(1000);
Serial.print("AT+CMGF=1\r");
delay(1000);
Serial.print("AT+CMGS="+91XXXXXXXXXX"\r"); //Number to which you want to send the sms is XXXXXXXXXX
delay(1000);
Serial.print("THIS IS A TEST MESSAGE \r"); //The text of the message to be sent
delay(1000);
Serial.write(0x1A);
delay(1000);
}
void loop()
{
}