I have also designed a GSM Library for Proteus using which you can easily now simulate your SIM900D module in Proteus. Sim900 Module is used to send and receive SMS and it is widely used in automation and security projects. I have also posted another Project in which I have designed the Proteus simulation of GSM based Home Security System. I have already posted the Send SMS with PIC Microcontroller & SIM900 project in which we have seen How to send SMS from your GSM module to your mobile phone but today we will send SMS from our mobile phone and then will receive this SMS on the SIM900 module and will perform certain action. Forexample you want to turn your Light ON using GSM then what you need to do is to send SMS from your mobile to SIM900 module and when it receives the message, it will do the required task. Moreover if you are working on Sending SMS instead of receiving then you should have a look at How to Send SMS with PIC Microcontroller & SIM900d and if this sending is via Arduino board then there's How to Send SMS with Arduino and Sim900.
I have used PIC18F452 for this project but you can use this code for any PIC Microcontroller but it has to support the serial port. Moreover, I have used MikroC Pro for PIC Compiler to design code for receive SMS with AT commands using SIM900 & PIC Microcontroller. So, let's have a look at How to Receive SMS with Sim900 & PIC Microcontroller using AT command.
char IncData; int x = 0; char RcvdMsg[60] = ""; int RcvdCheck = 0; int RcvdConf = 0; int index = 0; int RcvdEnd = 0; char MsgMob[15]; char MsgTxt[10]; int MsgLength = 0; void RecSMS(); void ClearBuffers(); void Config(); void main() { TRISC.F7 = 1; UART1_Init(9600); // Initialize UART module at 9600 bps Delay_ms(100); // Wait for UART module to stabilize Config(); while(1) { RecSMS(); } } void RecSMS() // Receiving the SMS and extracting the Sender Mobile number & Message Text { if (UART1_Data_Ready()) { IncData = UART1_Read(); //UART1_Write_Text(IncData); if(IncData == '+'){RcvdCheck = 1;} if((IncData == 'C') && (RcvdCheck == 1)){RcvdCheck = 2;} if((IncData == 'M') && (RcvdCheck == 2)){RcvdCheck = 3;} if((IncData == 'T') && (RcvdCheck == 3)){RcvdCheck = 4;} if(RcvdCheck == 4){index = 0;RcvdConf = 1; RcvdCheck = 0;} if(RcvdConf == 1) { if(IncData == 'n'){RcvdEnd++;} if(RcvdEnd == 3){RcvdEnd = 0;} RcvdMsg[index] = IncData; index++; if(RcvdEnd == 2){RcvdConf = 0;MsgLength = index-2;index = 0;} if(RcvdConf == 0) { //PortD.F3 = 1; //UART1_Write_Text("Mobile Number is: "); for(x = 4;x < 17;x++) { MsgMob[x-4] = RcvdMsg[x]; //UART1_Write(MsgMob[x-4]); } // UART1_Write_Text("Message Text: "); for(x = 46;x < MsgLength;x++) { MsgTxt[x-46] = RcvdMsg[x]; //UART1_Write(MsgTxt[x-46]); } if(MsgTxt[0] == 'A'){ PortD.F0 = 1;}//L1ON();} if(MsgTxt[0] == 'B'){ PortD.F0 = 0;}//L1OF();} if(MsgTxt[0] == 'C'){ PortD.F1 = 1;}//L2ON();} if(MsgTxt[0] == 'D'){ PortD.F1 = 0;}//L2OF();} if(MsgTxt[0] == 'E'){ PortD.F2 = 1;}//L3ON();} if(MsgTxt[0] == 'F'){ PortD.F2 = 0;}//L3OF();} if(MsgTxt[0] == 'G'){ PortD.F3 = 1;}//L4ON();} if(MsgTxt[0] == 'H'){ PortD.F3 = 0;}//L4OF();} ClearBuffers(); } } } } void ClearBuffers() { strcpy(RcvdMsg,""); RcvdCheck = 0; RcvdConf = 0; index = 0; RcvdEnd = 0; strcpy(MsgMob,""); strcpy(MsgTxt,""); MsgLength = 0; } void Config() { Delay_ms(2000); UART1_Write_Text("ATE0rn"); Delay_ms(1000); UART1_Write_Text("ATrn"); Delay_ms(1000); UART1_Write_Text("AT+CMGF=1rn"); Delay_ms(1000); UART1_Write_Text("AT+CNMI=1,2,0,0,0rn"); Delay_ms(1000); }
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w