Receive sms gsm module using pic microcontroller
Receive sms gsm module using pic microcontroller, In this article you will learn how to receive sms using gsm and pic microcontroller. I have already posted many articles on gsm and gsm module interfacing with pic microcontoller. Many users have asked me to post article on how to receive sms using gsm with pic microcontroller. First of all to use gsm module like SIM900A, SIM900B or many other versions available in market, you first should know how to use AT commands to get response from GSM module. Because the only way to interact with this module is through AT commands. Microcontroller sends specific AT commands to microcontroller and GSM module responds accordingly.
AT commands receive sms using gsm module
For example to send sms using GSM module and pic microcontroller, user have to use specific commands and similarly we can make call and answer phone call using this modem. So lets start with AT commands which are used to receive sms and how to read this sms and send date to UART of pic microcontroller. Because all these modules works on UART serial communication protocol. Following commands are used to receive sms and initialize modem that whenever it receive sms ,send this to UART pin of module. So that microcontroller can read it.
- AT :It will check the gsm module either it will connected with microcontroller or not and responds with ‘OK’ if it is connected.
- AT+CMGF=1 : this command sets the gsm module to text mode. Because we want to receive data in text format so that we can handle it easily while extracting sms from string which gsm will send to microcontroller. I will explain it in more detail in later part of this article.
- AT+CNMI=1,2,0,0,0 : This command force the gsm module to send receive sms gsm module to UART pins of microcontroller whenever sms is received. So that microcontroller can read it serially.
So these are the only three commands which will be used to to receive sms and send this sms to microcontroller.
Circuit diagram to receive sms using pic microcontroller
So now lets move to circuit diagram. Circuit diagram to receive sms is shown below. Circuit diagram remains same in all cases either you are sending or receiving sms.
So this is self explanatory circuit diagram. you just have to connect rx pin of gsm module with tx pin of microcontroller and tx pin of gsm with rx pin of microcontroller which is obvious that receiver of on is transmitter of other and vice versa. But make sure to connect power supply with gsm module which can supply peak current of 2A because while sending and receiving sms, it will take current in th order of two ampere.
I have used pic18f452 microcontroller while making this tutorial, but you can use any microcontroller you want and it depends on your application and selection of microcontroller depends on your microcontroller based project. you know what we can connect gsm module to com pin in proteus so its mean we can test our code by connect gsm module with computer or laptop and use this send data to proteus. So we can test our code without making actual hardware. But I recommend you test it on hardware.
Receive sms on computer or laptop
So first of all lets check, how our message string will look like when microcontroller receive it. For this purpose, we have to connect gsm module with computer or laptop. I have connected using usb to TTL converter as shown in figure below:
I have sent the sms from mobile number to sim in gsm module. I am using serial terminal proteus to receive sms as shown in figure below:
JLCPCB – Prototype 10 PCBs for $2 + 2 days Lead Time
China’s Largest PCB Prototype Enterprise, 300,000+ Customers & 10,000+ Online Orders Per Day
Inside a huge PCB factory: https://www.youtube.com/watch?v=_XCznQFV-Mw