Receive SMS

Hi guys, can you help me how to code for receiving sms? i have a code for sending sms and it works well but i dont know how to make a code for receiving sms. can you modify my code and add some code for receiving sms? i just want to receive 2 messages the ON or OFF. i am using sim900d and arduino mega 2560. here is my code.

void send_msg(char *number, char *msg)
  char at_cmgs_cmd[30] = {'\0'};
  char msg1[160] = {'\0'};
  char ctl_z = 0x1A;

  sprintf(msg1, "%s%c", msg, ctl_z);
  sprintf(at_cmgs_cmd, "AT+CMGS=\"%s\"\r\n",number);

void sendGSM(char *string){

Thanks in advance! :slight_smile:

I just asked a similar question, what shield are you using?

SIMCOM SIM900D. can you help me with this? or anyone else? :slight_smile:

I just found some sample code, not sure if this will work or not, good luck trying to find a tutorial, I have been searching for a while.

Thanks! what if i wont use the serial monitor? just when the module receive the text, it will read the message automatically and do the operation with respect to the message it receives?

I am actually trying to do the same thing, but yeah, just take out the functions you aren't using and modify it for what you need it to do. You just need to go through each line and see what it is doing.

Actually check out this: Receive SMS example - Arduino GSM Shield - Arduino Forum