I am using SIM 900 GSM and arduino mega.. I want to store the incoming call number and send an SMS to the same number for retrieving the incoming call number i used the following code
void setup()
{
Serial.begin(9600);
Serial3.begin(9600);
}
void loop()
{
if(Serial3.available())
{
Serial3.print("AT");
Serial3.print("AT+CLIP=1\r\n");
char c=Serial3.read();
Serial.print(c);
Serial3.print(c);
}
}
but when i execute this code it shows like
RING
CLIP="+91**********","145",""
AAAAAAAAAAAATTTTTTTTTTTTCCCCCCCCCCCCCCLLLLLLLLLLLLLLLIIIIIIIIIIIIIIIIIIIIIIIPPPPPPPPPPPP==========.........
what can i do for extract the number only?????
I suspect you're oversimplifying the use of the +CLIP command.
You don't just 'send it' to get the caller ID back.
The +CLIP message is sent asynchronously by the modem when an incoming 'call' is received (before the call is answered).
You need to to continuously monitor the serial stream in order to detect 'RING', 'CLIP' and other async messages.
SMS are a different proposition, as they contain the sender number within the message header.
Unfortunately a code snippet is not going to help, as this is effectively 'mult-tasking', and needs to be designed into your application.
Start by looking at Serialevent() to learn how you can work with unexpected serial Comms.