sim900 gsm module pakistan,gsm sim900D module in pakistan, sim900D prices in pakistan, send sms via sim900D and arduino uno, send sms via AT commands
Hello friends, in today's post I am gonna show how to send SMS with PIC Microcontroller and SIM900. In my previous posts, we have seen how to Send SMS with Arduino and SIM900D and have also seen how to Receive SMS with Arduino and sim900D, both of them were using Arduino board. So, today I thought to post same project using PIC Microcontroller. The logics I am gonna use are exactly the sameas I did for Arduino but the only thing gonna change is the programming syntax. I am using MikroC Pro for PIC compiler for PIC Microcontroller and PIC18F452 is gonna use here. I have also posted on How to Receive SMS with AT Commands using SIM900 & PIC Microcontroller, so check it out as well if you are planning to work on PIC Microcontroller and SIM900.

There are different GSM modules available in the market but they all work on the same principal. They all are operated via Serial port, also known as UART, and are controlled via AT commands. You need to connect the PIC Microcontroller with GSM module via TX / RX pins and you are ready to start working on it. Today, I am gonna share how to send SMS with PIC Microcontroller and SIM900 and in the next post I will share how to receive SMS with SIM900 on PIC Microcontroller. So, lets start with it.

Send SMS With PIC Microcontroller & SIM900

  • Sim900 shield I am gonna use is shown below, but if you don't have this one then no need to panic, simply find the TX and RX pins from your Sim900 shield.
sim900 gsm module pakistan,gsm sim900D module in pakistan, sim900D prices in pakistan, send sms via sim900D and arduino uno, send sms via AT commands
  • As you can see above I have mentioned the TX and RX pins, so you are gonna just need these two pins and connect them with PIC Microcontroller. The connections will be:
    • RX pin of Sim900 into Pin # 25 (TX) of PIC Microcontroller.
    • TX pin of Sim900 into Pin # 26 (RX) of PIC Microcontroller.
  • One more thing you will also need the basic circuit of PIC Microcontroller, which is as follows:
Getting Started with PIC Microcontrollers
  • Finally, don't forget to make the GND common for PIC Microcontroller and Sim900, as PIC Microcontroller is working on 5V while the GSM module is working on 12V. There are also GSM modules available which work on 5V or 3.3V. So, whatever the case, just make sure their GND is common with GND of PIC Microcontroller.
  • So, now I hope you are done with the connections and ready to start with programming, so open your MikroC Pro for PIC compiler and upload the below code into it.
void Initialization() { UART1_Init(9600);   // Initialize Serial Port at 9600 baud rate } void SendSms() { Delay_ms(2000); UART1_Write_Text("ATE0rn");   // AT command for Echo OFF 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); UART1_Write_Text("AT+CMGS="+923326062060"rn"); delay_ms(500); UART1_Write_text("www.TheEngineeringProjects.com rn"); UART1_Write(26); } void main() { delay_ms(5000); delay_ms(5000); Initialization(); SendSms(); do { } while(1); }
  • Its quite a simple code, in which I first initialized the serial port at 9600 bad rate and after that I sent AT commands to our SIM900 module, which will then send the SMS.
  • In the above code, change the mobile number which I have highlighted and also change the message body, change it with whatever you wanna send. Right now I am sending www.TheEngineeringProjects.com which is my website. :P
  • The AT commands description is as follows:
    • ATE0: It is used to turn off the Echo of Sim900 module.
    • AT: It is used to test the Sim900 module.
    • AT+CMGF = 1: This command is converting our Sim900 module to text mode.
    • AT+CNMI=1,2,0,0,0: This command is configuring our Sim900 module. Its not compulsary but is better to use, its actual benefit will be in the next tutorial of receving sms.
    • AT+CMGS: This is the actual command to send the SMS. It gets number and SMS body and then send the sms.
Note:
  • In all AT commands, we need to press Enter in order to send that command to SIM900, that's why I have used rn after every command.
  • But for AT+CMGS command, we have to use Cntrl+Z after sending the command and thaat's why I have used UART1_Write(26); where 26 is the ascii code for Cntrl+Z.

That's all for today, hope it will help you in some way. I have also posted on How to Receive SMS with AT Commands using SIM900 & PIC Microcontroller, so check it out as well if you are planning to work on PIC Microcontroller and SIM900. Till then have fun. :)