GSM Module SIM300 Interface With AVR Amega32 _ EXtreme Electronics

52
12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/ 1/52 (http://extremeelectronics.co.in/rform/register.php?ref=eehead) GSM Module SIM300 Interface with AVR Amega32 Posted On 29 Jul 2012 By Avinash (http://extremeelectronics.co.in/author/Avinash/) In AVR Tutorials (http://extremeelectronics.co.in/category/avr-tutorials/)

description

gsm module

Transcript of GSM Module SIM300 Interface With AVR Amega32 _ EXtreme Electronics

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 1/52

(http://extremeelectronics.co.in/rform/register.php?ref=eehead)

GSM Module SIM300 Interface withAVR Amega32Posted On 29 Jul 2012 By Avinash (http://extremeelectronics.co.in/author/Avinash/)

In AVR Tutorials (http://extremeelectronics.co.in/category/avr-tutorials/)

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 2/52

If you want a live demo of this, please register from the link given below. (Only inPune) REGISTER NOW! (http://extremeelectronics.co.in/rform/register.php)

This project can also be implemented using a PIC18F4520 microcontroller. We haveschematic and C library available.

A GSM/GPRS Module (http://store.extremeelectronics.co.in/GSM-GPRS-Modem-SIM300-KIT.html)like SIM300 can be used for any embedded application that requires a long rangecommunication, like a robot in Chennai controlled by a person sitting in New Delhi! Or simply awater pump in a rice field turned on in the morning by a farmer sitting in his house fewkilometers away! You have few communication options depending on the application, they maybe as follows.

Simple SMS based communicationTurn on/off loads using simple SMS commands, so the controlling device is a standardhandset. You can use any mobile phone to control the device.A intruder alarm/fire alarm that informs about the panic situation to the house owner onhis/her mobile via SMS.

Call based communicationA smart intruder alarm/fire alarm that calls the police or fire station and plays a prerecorded audio message to inform about the emergency.

Internet Based Communication (GPRS)User can control the end application using any PC/Tablet/Mobile with internet connection.Example: LED Message Displays installed on highways/expressways controlled from acentral control room to inform users or traffic conditions ahead.A robot controlled over internet. That means the robot can be accessed from any devicehaving internet any where in the world.A portable device installed on vehicles that connects to internet using the GPRS ModuleSIM300 and uploads current position(using Global Position System) to a server. The serverstores those location in a database with the ID of vehicle. Then a client(using a PC) canconnect with the server using World Wide Web to see the route of the vehicle.

Advantage of using SIM300 Module.The SIM300 KIT (http://store.extremeelectronics.co.in/GSM-GPRS-Modem-SIM300-KIT.html) is afully integrated module with SIM card holder, power supply etc. This module can be easilyconnected with low cost MCUs like AVR/PIC/8051. The basic communication is over asynchronousserial line (http://extremeelectronics.co.in/avr-tutorials/rs232-communication-the-basics/). Thisis the most basic type of serial communication that’s why it is very popular and hardwaresupport is available in most MCUs. The data is transmitted bit by bit in a frame consisting acomplete byte. Thus at high level it is viewed as a simple text stream. Their are only two streamsone is from MCU to SIM300 and other is from SIM300 to MCU. Commands are sent as simple text.Their are several tutorials that describes how to send and receive strings over the serial line.

Using the USART of AVR MCU (http://extremeelectronics.co.in/avr-tutorials/using-the-usart-

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 3/52

Using the USART of AVR MCU (http://extremeelectronics.co.in/avr-tutorials/using-the-usart-of-avr-microcontrollers/)Using the USART of AVR MCU – Sending and Receiving data.(http://extremeelectronics.co.in/avr-tutorials/using-the-usart-of-avr-microcontrollers-reading-and-writing-data/)

If you have never heard of serial communication and never did it in practice then it is highlyrecommend to go and understand clearly using some thing simpler (experiments given in abovelinks).

Communication with SIM300 Module usingAVR UART.The hardware(inside the AVR MCU Chip) that is used to to serial communication is called theUART, we use this UART to communicate with the SIM300 module (the UART can also be used tocommunicate with other devices like RFID Readers, GPS Modules, Finger Print Scanner etc.). SinceUART is such a common method of communication in embedded world that we have made aclean and easy to use library that we use in all our UART based projects.

Since a byte can arrive to MCU any time from the sender (SIM300), suppose if the MCU is busydoing something else, then what happens? To solve this, we have implemented a interrupt basedbuffering of incoming data. A buffer is maintained in the RAM of MCU to store all incomingcharacter. Their is a function to inquire about the number of bytes waiting in this queue.

Following are the functions in AVR USART library

void USARTInit(uint16_t ubrrvalue)

Initializes the AVR USART Hardware. The parameter ubrrvalue isrequired to set desired baud rate for communication. By default SIM300communicates at 9600 bps. For an AVR MCU running at 16MHz theubrrvalue comes to be 103.

char UReadData()

Reads a single character from the queue. Returns 0 if no data isavailable in the queue.

void UWriteData(char data)

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 4/52

void UWriteData(char data)

Writes a single byte of data to the Tx Line, used by UWriteString()function.

uint8_t UDataAvailable()

Tells you the amount of data available in the FIFO queue.

void UWriteString(char *str)

Writes a complete C style null terminated string to the Tx line.

Example #1:

UWriteString("Hello World !");

Example #2:

char name[]="Avinash !";     UWriteString(name);

 

void UReadBuffer(void *buff,uint16_t len)

Copies the content of the fifo buffer to the memory pointed by buff, the

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 5/52

Copies the content of the fifo buffer to the memory pointed by buff, theamount of data to be copied is specified by len parameter. If UARTincoming fifo buffer have fewer data than required (as per lenparameter) then latter areas will contain zeros.

Example:

char gsm_buffer[128];     UReadBuffer(gsm_buffer,16);

The above example will read 16 bytes of data (if available) fromthe incoming fifo buffer to the variable gsm_buffer. Please notethat we have allocated gsm_buffer as 128 byte array becauselatter we may need to read more than 16 bytes. So the samebuffer can be used latter to read data up to 128 bytes.

The above function is used generally along with UDataAvailable()function.

while(UDataAvailable()<16)     {       //Do nothing     }  

char gsm_buffer[128];     UReadBuffer(gsm_buffer,16);

The above code snippet waits until we have 16 bytes of dataavailable in the buffer, then read all of them.

 void UFlushBuffer()

Removes all waiting data in the fifo buffer. Generally before sendingnew command to GSM Module we first clear up the data waiting in thefifo.

The above functions are used to send and receive text stream from the GSM Module SIM300.

SIM300 AT Command Set

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 6/52

SIM300 AT Command SetNow you know the basics of AVR USART library and how to use it to initialize the USART, sendand receive character data, its time for us to move ahead and look what commands areavailable with SIM300 module and how we issue commands and check the response. SIM300supports several functions like sending text messages, making phone call etc. Each of the tasks isdone using a command, and sim300 has several commands known as the command set.

All SIM300 commands are prefixed with AT+ and are terminated by a Carriage Return (or <CR> inshort). The ASCII code of CR is 0x0D (decimal 13). Anything you write to SIM300 will be echoedback from sim300′s tx line. That means if you write a command which is 7 bytes long (includingthe trailing CR) then immediately you will have same 7 bytes in the MCU’s UART incoming buffer.If you don’t get the echo back then it means something is wrong !

So the first function we develop is SIM300Cmd(const char *cmd) which does the following job :-

(NOTE: All sim300 related function implementations are kept in file sim300.c, and prototypes andconstants are kept in sim300.h)

Writes the command given by parameter cmd.Appends CR after the command.Waits for the echo, if echo arrives before timeout it returns SIM300_OK(constant defined insim300.h). If we have waited too long and echo didn’t arrive then it returns SIM300_TIMEOUT.

Implementation of SIM300Cmd()

int8_t SIM300Cmd(const char *cmd) 

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 7/52

int8_t SIM300Cmd(const char *cmd) {    UWriteString(cmd);   //Send Command    UWriteData(0x0D); //CR 

   uint8_t len=strlen(cmd); 

   len++;   //Add 1 for trailing CR added to all commands 

   uint16_t i=0; 

   //Wait for echo    while(i<10*len)    {       if(UDataAvailable()<len)       {          i++; 

         _delay_ms(10); 

         continue;       }       else       {          //We got an echo          //Now check it          UReadBuffer(sim300_buffer,len);  //Read serial Data 

         return SIM300_OK; 

      }    } 

   return SIM300_TIMEOUT; 

Commands are usually followed by a response. The form of the response is like this

<CR><LF><response><CR><LF>

LF is Line Feed whose ASCII Code is 0x0A (10 in decimal)

So after sending a command we need to wait for a response, three things can happen whilewaiting for a response :

No response is received after waiting for a long time, reason can be that the SIM300 is notconnected properly with the MCU.Response is received but not as expected, reason can be faulty serial line or incorrent baudrate setting or MCU is running at some other frequency than expected.

Correct response is received.

For example, command Get Network Registration is executed like this :-

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 8/52

For example, command Get Network Registration is executed like this :-

Command String: "AT+CREG?"

Response:

<CR><LF>+CREG: <n>,<stat><CR><LF>

<CR><LF>OK<CR><LF>

So you can see the correct response is 20 bytes. So after sending command "AT+CREG?" we waituntil we have received 20 bytes of data or certain amount of time has elapsed. The secondcondition is implemented to avoid the risk of hanging up if the sim300 module malfunctions.That means we do not keep waiting forever for response we simply throw error if SIM300 istaking too long to respond (this condition is called timeout)

If correct response is received we analyses variable <stat> to get the current networkregistration.

depending on current network registration status the value of stat can be

0 – not registered, SIM300 is not currently searching a new operator to register to1 registered, home network2 not registered, but SIM300 is currently searching a new operator to register to3 registration denied4 unknown5 registered, roaming

Implementation of SIM300GetNetStat() Function

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 9/52

int8_t SIM300GetNetStat() {    //Send Command   SIM300Cmd("AT+CREG?"); 

   //Now wait for response    uint16_t i=0; 

   //correct response is 20 byte long    //So wait until we have got 20 bytes    //in buffer.    while(i<10)    {       if(UDataAvailable()<20)       {          i++; 

         _delay_ms(10); 

         continue;       }       else       {          //We got a response that is 20 bytes long          //Now check it          UReadBuffer(sim300_buffer,20);   //Read serial Data 

         if(sim300_buffer[11]=='1')             return SIM300_NW_REGISTERED_HOME;          else if(sim300_buffer[11]=='2')             return SIM300_NW_SEARCHING;          else if(sim300_buffer[11]=='5')             return SIM300_NW_REGISTED_ROAMING;          else             return SIM300_NW_ERROR;       }    } 

   //We waited so long but got no response    //So tell caller that we timed out 

   return SIM300_TIMEOUT; 

Similarly we have implemented the following functions :-

int8_t SIM300IsSIMInserted()

In another type of response we don’t exactly know the size of response like we knew for theabove command. Example is the Get Service Provider Name command where the provider name’s

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 10/52

above command. Example is the Get Service Provider Name command where the provider name’slength cannot be known in advance. It can be Airtel or Reliance or TATA Docomo. To handle thatsituation we make use of the fact that all response are followed by a CR LF pair. So we simplebuffer in all characters until we encounter a CR, that indicates end of response.

To simplify handling of such commands we have made a function calledSIM300WaitForResponse(uint16_t timeout)

This function waits for a response from SIM300 module (end of response is indicated by a CR), itreturns the size if response received, while the actual response is copied to the global variablesim300_buffer[].

If no response is received before timeout it returns 0. Timeout in millisecond can be specified bythe parameter timeout. It does not count the trailing LF or the last <CR><LF>OK<CR><LF>, theyremain in the UART fifo queue. So before returning we call UFlushBuffer() to remove those fromthe queue.

Implementation of function SIM300WaitForResponse(uint16_t timeout)

int8_t SIM300WaitForResponse(uint16_t timeout) {    uint8_t i=0;    uint16_t n=0; 

   while(1)    {       while (UDataAvailable()==0 && n<timeout){n++; _delay_ms(1);} 

      if(n==timeout)          return 0;       else       {          sim300_buffer[i]=UReadData(); 

         if(sim300_buffer[i]==0x0D && i!=0)             return i+1;          else             i++;       }    } } 

Implementation of function SIM300GetProviderName(char *name)

The function does the following :-

1. Flush the USART buffer to get rid of any leftover response from the last command orerrors.

2. It send the command "AT+CSPN?" using SIM300Cmd("AT+CSPN?"); function call.

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 11/52

3. Then it waits for a response using the function SIM300WaitForResponse()4. If we receive a response of non zero length we parse it to extract string describing the

service provider name.5. If SIM300WaitForResponse() returns zero that means no valid response is received within

specified time out period. In this case we also return SIM300_TIMEOUT.

In the same way we have implemented the following functions :-

uint8_t SIM300GetProviderName(char *name)int8_t SIM300GetIMEI(char *emei)int8_t SIM300GetManufacturer(char *man_id)int8_t SIM300GetModel(char *model)

uint8_t SIM300GetProviderName(char *name) {    UFlushBuffer(); 

   //Send Command   SIM300Cmd("AT+CSPN?"); 

   uint8_t len=SIM300WaitForResponse(1000); 

   if(len==0)       return SIM300_TIMEOUT; 

   char *start,*end;    start=strchr(sim300_buffer,'"');    start++;    end=strchr(start,'"'); 

   *end='\0'; 

   strcpy(name,start); 

   return strlen(name); } 

SIM300 and ATmega32 Hardware Setup

NOTE: To learn AVR Microcontrollers and do hands onexperiments at home you can purchase xBoard. It is alow cost development board designed to get startedwith minimum efforts and to easily perform common

tasks. Lots of sample programs helps you easilycomplete projects. It is a must have tool if you want todo something real and instead of just wasting time justtrying to achieve basic things and avoid problems that

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 12/52

trying to achieve basic things and avoid problems thatdont let you move forward to the real task.

Buy xBoard NOW !(http://extremeelectronics.co.in/wp‐content/plugins/product_box/click.php?code=x_board)

Free shipping across India ! Pay Cash on Delivery ! 15Days Money Back!

To run the basic demo showing communication with SIM300 using AVR ATmega32 we need thefollowing circuit :-

ATmega32 Core circuit, including the reset register, ISP header, 16MHz crystal oscillator.Power Supply circuit to supply 5v to the ATmega32 and the LCD Module(http://extremeelectronics.co.in/avr-tutorials/using-lcd-module-with-avrs/).A 16×2 Alphanumeric LCD Module (http://extremeelectronics.co.in/avr-tutorials/using-lcd-module-with-avrs/) to show programs output.SIM300 Module (http://store.extremeelectronics.co.in/GSM-GPRS-Modem-SIM300-KIT.html).

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 13/52

(http://www.extremeelectronics.co.in/avrtutorials/images/avr_atmega32_lcd_sim300.gif)

Fig. SIM300 and ATmega32 Schematic

We have made the prototype using xBoard (http://store.extremeelectronics.co.in/xBoard-v2.0.html) development board because it has ATmega32 core circuit, 5v power supply circuit andthe LCD module.

Fig. SIM300 and ATmega32 Connection

 

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 14/52

 

Fig. SIM300′s PINs

 

Fig. xBoard’s USART PINs

 

 

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 15/52

 

 

Fig. GSM Module connected with ATmega32

NOTEThe board shown below is the new version of SIM300 Modem(http://store.extremeelectronics.co.in/GSM-GPRS-Modem-SIM300-KIT-v2.html), it can also beused to make this project. New version is much smaller and low cost.

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 16/52

(http://store.extremeelectronics.co.in/GSM-GPRS-Modem-SIM300-KIT-v2.html)

Fig. SIM300 Module New Version

 

Demo Source Code for AVR and SIM300InterfaceThe demo source code is written in C language and compiled using free avr-gcc compiler usingthe latest Atmel Studio 6 IDE. The project is split into the following modules.

LCD LibraryFiles lcd.c, lcd.h, myutils.h, custom_char.hJob is to control standard 16×2 LCD Module.More information on LCD library.(http://xboard.extremeelectronics.co.in/Name_In_LCD.htm)

USART LibraryFiles usart.c,usart.hJob is to control the USART hardware of AVR MCU. Includes functions to initialize theUSART, Send/Receive chars, Send/Receive Strings.

SIM300 LibraryFiles sim300.c, sim300.h

To build the project you need to be have working knowledge of the Atmel Studio 6 IDE. Pleaserefer to the following tutorial.

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 17/52

Working with latest Atmel Studio 6 IDE. (http://extremeelectronics.co.in/lfrm8/Help/AS6.htm)

Steps to configure the AS6 Project

Create a new AS6 Project with name "Sim300Demo".Using solution explorer(http://extremeelectronics.co.in/lfrm8/Help/AS6.htm#SOLUTION_EXPLORER) create a foldernamed "lib" in current folder.Inside the "lib" folder create the following sub folders "lcd", "usart" and "sim300".copy followings files to the lcd folder (using Windows File Manager) lcd.c, lcd.h, myutils.h,custom_char.hcopy followings files to the usart folder (using Windows File Manager) usart.c,usart.hcopy followings files to the sim300 folder (using Windows File Manager sim300.c, sim300.hAdd the files (http://extremeelectronics.co.in/lfrm8/Help/AS6.htm#ADD_EXISTING_ITEM) lcd.c,lcd.h, myutils.h, custom_char.h to the project using solution explorer(http://extremeelectronics.co.in/lfrm8/Help/AS6.htm#ADD_EXISTING_ITEM).Add the filesusart.c,usart.h to the project using solution explorer.Add the files sim300.c, sim300.h to the project using solution explorer.Define a symbol(http://extremeelectronics.co.in/lfrm8/Help/AS6.htm#ADD_EXISTING_ITEM)F_CPU=16000000using AS6′sin the main application file Sim300Demo.c copy paste the following demo program.Build the project to get the executable hex file.Burn this hex file to the xBoard using USB AVR Programmer.(http://store.extremeelectronics.co.in/USB-AVR-Programmer-v2.1.html)If you are using a new ATMega32 MCU from the market set the LOW FUSE as 0xFF and HIGHFUSE are 0xC9.

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 18/52

Fig.: Setting the Fuse bytes.

/*  * Sim300Demo.c  *  * Created: 10‐07‐2012 PM 12:23:08  *  Author: Avinash 

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 19/52

 *  Author: Avinash  */ 

#include <avr/io.h> #include <util/delay.h> 

#include "lib/lcd/lcd.h" #include "lib/sim300/sim300.h" 

void Halt(); int main(void) {    //Initialize LCD Module    LCDInit(LS_NONE); 

   //Intro Message    LCDWriteString("SIM300 Demo !");    LCDWriteStringXY(0,1,"By Avinash Gupta"); 

   _delay_ms(1000); 

   LCDClear(); 

   //Initialize SIM300 module    LCDWriteString("Initializing ...");    int8_t r= SIM300Init(); 

   _delay_ms(1000); 

   //Check the status of initialization    switch(r)    {       case SIM300_OK:          LCDWriteStringXY(0,1,"OK !");          break;       case SIM300_TIMEOUT:          LCDWriteStringXY(0,1,"No response");          Halt();       case SIM300_INVALID_RESPONSE:          LCDWriteStringXY(0,1,"Inv response");          Halt();       case SIM300_FAIL: 

         LCDWriteStringXY(0,1,"Fail");          Halt();       default:          LCDWriteStringXY(0,1,"Unknown Error");          Halt();    } 

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 20/52

   _delay_ms(1000); 

   //IMEI No display    LCDClear(); 

   char imei[16]; 

   r=SIM300GetIMEI(imei); 

   if(r==SIM300_TIMEOUT)    {       LCDWriteString("Comm Error !");       Halt();    } 

   LCDWriteString("Device IMEI:");    LCDWriteStringXY(0,1,imei); 

   _delay_ms(1000); 

   //Manufacturer ID    LCDClear(); 

   char man_id[48]; 

   r=SIM300GetManufacturer(man_id); 

   if(r==SIM300_TIMEOUT)    {       LCDWriteString("Comm Error !");       Halt();    } 

   LCDWriteString("Manufacturer:");    LCDWriteStringXY(0,1,man_id); 

   _delay_ms(1000); 

   //Manufacturer ID    LCDClear(); 

   char model[48]; 

   r=SIM300GetModel(model); 

   if(r==SIM300_TIMEOUT)    {       LCDWriteString("Comm Error !");       Halt();    } 

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 21/52

   LCDWriteString("Model:");    LCDWriteStringXY(0,1,model); 

   _delay_ms(1000); 

   //Check Sim Card Presence    LCDClear();    LCDWriteString("Checking SIMCard"); 

   _delay_ms(1000); 

   r=SIM300IsSIMInserted(); 

   if (r==SIM300_SIM_NOT_PRESENT)    {       //Sim card is NOT present       LCDWriteStringXY(0,1,"No SIM Card !"); 

      Halt();    }    else if(r==SIM300_TIMEOUT)    {       //Communication Error       LCDWriteStringXY(0,1,"Comm Error !"); 

      Halt();    }    else if(r==SIM300_SIM_PRESENT)    {       //Sim card present       LCDWriteStringXY(0,1,"SIM Card Present"); 

      _delay_ms(1000);    } 

   //Network search    LCDClear();    LCDWriteStringXY(0,0,"SearchingNetwork"); 

   uint8_t     nw_found=0;    uint16_t tries=0;    uint8_t     x=0; 

   while(!nw_found)    {       r=SIM300GetNetStat(); 

      if(r==SIM300_NW_SEARCHING)       { 

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 22/52

         LCDWriteStringXY(0,1,"%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0");          LCDWriteStringXY(x,1,"%1");          LCDGotoXY(17,1); 

         x++; 

         if(x==16) x=0; 

         _delay_ms(50); 

         tries++;

         if(tries==600)             break;       }       else          break; 

   }    LCDClear(); 

   if(r==SIM300_NW_REGISTERED_HOME)    {       LCDWriteString("Network Found");    }    else    {       LCDWriteString("Cant Connt to NW!");       Halt();    } 

   _delay_ms(1000); 

   LCDClear(); 

   //Show Provider Name    char pname[32];    r=SIM300GetProviderName(pname); 

   if(r==0)    {       LCDWriteString("Comm Error !");       Halt();    } 

   LCDWriteString(pname); 

   _delay_ms(1000); 

   Halt(); } 

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 23/52

void Halt() {    while(1); } 

What the Demo Program does?Initializes the LCD Module and SIM300 module.Check if the SIM300 module is present on the USART and responding properly.Displays the IMEI No of the SIM300 Module.Displays Manufacturer IDThen checks for the SIM card presence.Searches for a GSM Network and establishes a connection. The sim card need to be valid inorder to connect to the GSM network.Shows the Network Provider’s name like Airtel or Vodafone.

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 24/52

Android Smartphone Controlled Home Appliances !  Watch Now(http://extremeelectronics.co.in/wp­content/plugins/ad_band/click.php?id=2)

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 25/52

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 26/52

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 27/52

TroubleshootingNO Display on LCD

Make sure AVR Studio Project is set up for clock frequency of 16MHz (16000000Hz)Adjust the Contrast Adj Pot.Press reset few times.Power On/Off few times.Connect the LCD only as shown on schematic above.

On SIM300 Initialization phase if you get error "No Response"Check Rx,Tx and GND line connection between SIM300 and the xBoard.Make sure crystal frequency is 16MHz only.Fuse bits are set as described above.

Compiler Errors1. Many people these days has jumped to embedded programming without a solid concept

of computer science and programming. They don’t know the basics of compiler and lackexperience. To learn basic of compilers and their working PC/MAC/Linux( I mean adesktop or laptop) are great platform. But embedded system is not good for learningabout compilers and programming basics. It is for those who already have these skillsand just want to apply it.

2. Make sure all files belonging to the LCD Library are "added" to the "Project".3. avr-gcc is installed. (The Windows Binary Distribution is called WinAVR

(http://winavr.sourceforge.net/))4. The AVR Studio project Type is AVR GCC.5. Basics of Installing and using AVR Studio with avr-gcc is described in this tutorial

(extremeelectronics.co.in/lfrm8/Help/AS6.htm)General Tips for newbies

Use ready made development boards (http://store.extremeelectronics.co.in/Development-Boards/) and programmers (http://store.extremeelectronics.co.in/Programmers/).Try to follow the AVR Tutorial Series (http://extremeelectronics.co.in/category/avr-tutorials/page/4/) from the very beginning. (Remember the list spans four pages, page 1 is

most recent addition thus most advance)

Downloads for GSM Module Demo.Atmel Studio 5 Project for SIM300 Demo.(http://extremeelectronics.co.in/avrtutorials/code/Sim300Demo_AS5_Project.zip)Atmel Studio 6 Project for SIM300 Demo.HEX File Ready to Burn on ATmega32 running at 16MHz.

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 28/52

(http://extremeelectronics.co.in/avrtutorials/code/Sim300Demo_HEX.zip)SIM300 Complete Command Set.(http://extremeelectronics.co.in/datasheets/SIM300DATC.pdf)

Liked this Article ? Want More ?Well see this !

Sending and Receiving Message using SIM300 (http://extremeelectronics.co.in/avr-tutorials/sending-an-receiving-sms-using-sim300-gsm-module/)

Help Us!We try to publish beginner friendly tutorials for latest subjects in embedded system as fast as wecan. If you like these tutorials and they have helped you solve problems, please help us inreturn. You can donate any amount as you like securely using a Credit or Debit Card or Paypal.

We would be very thankful for your kind help.

ByAvinash Gupta

Facebook (http://www.facebook.com/profile.php?id=100000536005502), Follow on Twitter(http://twitter.com/eXtremeElec).

www.AvinashGupta.com (http://www.AvinashGupta.com)[email protected] (mailto:[email protected])

Avinash(http://extremeelectronics.co.in/author/Avinash/)Avinash Gupta is solely focused on free and high quality tutorial to make learningembedded system fun !

More Posts (http://extremeelectronics.co.in/author/Avinash/) - Website(http://extremeelectronics.co.in)

Follow Me:

(http://www.facebook.com/avinash.gupta.x)

(http://www.linkedin.com/in/avinashgupta2)

(https://plus.google.com/u/0/100307363249325396529)

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 29/52

Line Following Robot using AVR ATmega8 ... Sending and Receiving SMS using SIM300 GS...

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=42803#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=42821#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=42824#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=42826#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=42827#respond)

86 thoughts on “GSM Module SIM300 Interfacewith AVR Amega32”

By Binu - July 29, 2012 1:31 pm

Nice tutorial for GSM, any idea for GPRS communication tutorial. Also one more thing, just blur the imei number on the LCD. Since its not safe to showthe imei number on web.

By alemt - July 30, 2012 3:15 pm

nice tutorial avinach i want to ask about if you will do a tutorial about connecting the sdcard memory and thank in advanced

By Ganesh - July 30, 2012 4:15 pm

Nice…please add the tutorial for GPS.

By Murali - July 30, 2012 6:44 pm

Thanks for one more great article.

By Avinash - July 30, 2012 6:46 pm

Thanks you liked it !

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 30/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=43413#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=43589#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?

Pingback: Sending an Receiving SMS using SIM300 GSM Module | eXtreme Electronics(http://extremeelectronics.co.in/avr-tutorials/sending-an-receiving-sms-using-sim300-gsm-module/)

By Gangster - August 22, 2012 9:26 am

Hi avinash really awesum tutorials…man….!! i m working on AVR microcontrollers. I used various development board but reallythose boards needs to be upgraded… so i m plaining to designed my owndevelopment board…. I have no issues with the interfacing any component or circuit…. Just need your help in designing PCB layout….. I can do that small less complicated circuit but for the huge complex complex circuit.. i dont know but i m worried about it a little…. can u provide me a tutorial on designing PCB layout… in the extremeelectronicsstyle…. i m totally impressed the way u explain things….. just waiting for tutorial on thistopic from your side….

Pingback: SMS Based Voting System – AVR GSM Project | eXtreme Electronics(http://extremeelectronics.co.in/avr-projects/sms-based-voting-system/)

By Vishal - August 28, 2012 1:00 pm

Hello Nice Tutorial…I am working on GSM Modem SIm300 with 8051 Micro. When i got message NO DIAL TONE from modem, Micro gets hanged up.I tried resetCommand also to reset GSM Modem but with no success. To solve it i gave a delay of approx 2 minute. After that it work properly. Any idea tosolve it without using delay.

One problem arises. When i made a call to only one number again and again, itworks properly. But when i call to two numbers one after the other in a loop, it worksonly for one time and after that micro gets hanged.

Any idea to solve above two problems.

By y2k_eng - September 10, 2012 10:52 am

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 31/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=43877#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=43880#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=43937#respond)

Hi, I am impressed the way you taught things , where i can get the whole code. I have simcom 908 and i am planing to do the same and the way you explain is reallyvery helpful. With best wishes

By Avinash - September 10, 2012 11:03 am

Thanks!

where i can get the whole code.

Please look clearly at the article once again and you will get a heading called“Downloads” under it their it a link which clearly states the download!

By diya - March 2, 2013 1:30 pm

what will be the difference if we are using an arduino board?

By Avinash - March 2, 2013 1:35 pm

@Diya

lots of difference and I don’t have the time to list.

By abhilash - September 13, 2012 10:10 pm

Hi Avinash,

you are a killer man…….you are just fantastic thnx a ton or this amazing tutorials….this thingwas not so easy before…….you are amzing…hats off…:)

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 32/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=43948#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=44109#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=44111#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=44112#respond)

was not so easy before…….you are amzing…hats off…:)

By Avinash - September 14, 2012 11:42 am

@Abhilash

Thanks !

By Parminder Singh - September 20, 2012 12:18 pm

Hi Avinash,

I bought one RF ID reader and one GSM modem from ur website. Is it possible to connect these two with one UART ? Bcoz I am using ATmega32. So plstell me how to use it.

By Gangster - September 20, 2012 1:06 pm

Better use Atmega324 having two usart..!!!

By gaurav - September 20, 2012 1:25 pm

You are right,but cost of Atmega324 is double than Atmega32.So it is better touse Atmega32 with software USART. Thank

you.

By gaurav - September 20, 2012 1:16 pm

Yes Parminder, it is certainly possible to connect one RF ID and one GSM modemwith one Atmega32.For this you can hire a developer or give it to a consultancy

firm.Further,we can help you.Connect one of device with hardware USART andanother one with software USART.A soft USART library helps in connecting more

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 33/52

another one with software USART.A soft USART library helps in connecting morethan one

serial devices to a MCU which only has a single hardware USART. For example youmay connect a GSM Module and GPS Module at the same time to a low cost MCUlike

ATmega8. Otherwise you have to look for a MCU which has two serial ports, butthat will be a costly option. So this library helps you emmulate a second softwareserial

port! Thank you

By Parminder Singh - September 21, 2012 10:43 am

Hi Gaurav,

Thanks for your response. Where will I get this Software library for serial port ?

Pls reply soon.

Thanks in advance.

By gaurav - September 21, 2012 11:44 am

Parminder,you have to made the software library by yourself or you can getthis made from a consultancy firm. Thank you

By Gangster - September 21, 2012 1:21 pm

@ it is certainly possible to connect one RF ID and one GSM modem with oneAtmega32.For this you can hire a developer or give it to a consultancy…..

i would like to pay for Atmega324….instead.. why to make things complicated when we can actually minimize thecomplexity… Parminder bro i still suggest atmega324…rest up to u….

By Parminder Singh - September 21, 2012 1:31 pm

Thanks brother. I will try to do this.

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 34/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=44150#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=44360#respond)

By Avinash - September 21, 2012 1:43 pm

@Gangster, you are confusing “smart” solution with “complication”

If all engineers start thinking like you, we wont get multimedia branded mobile@Rs. 2500/-!

Which few years back, used to costs Rs. 25K!

And mobile calls would have never been be free ! And in reach off all !

Even if you consider a product with minimal life time and produced only 100units. That will save you Rs. 20000/- ! (considering Rs 200 over head on eachproduct).

And I wrote a soft USART in 2 hours flat! So I saved Rs. 20,000 in just 2 hours !

By Gangster - September 21, 2012 3:36 pm

@avinash

well i thought he was planing to make a single piece and to hire a developer andgive him his consaltancy for the same will cost him more than a 324. if he can do it by his own then there is no better option than using a soft usart.

By Avinash - September 21, 2012 4:01 pm

Actually I thought he is a professional guy that’s why pointed him aprofessional solution, I did not knew if he was some child playing with a toy !Ha ha one piece ? Why would any one make 1 piece!!! At least if he is in thefield, he may face similar situation atleast twice ! What do you say ?

By Abdul Majeed - September 29, 2012 12:51 pm

@avinash Which design software do you use?

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 35/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=44361#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=44400#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=44995#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=50150#respond)

By Avinash - September 29, 2012 1:01 pm

@Abdul To design what? Schematic, Layout, Images, System Modeling or Design Software?

By Abdul Majeed - September 29, 2012 1:10 pm

@avinash like proteus or any other To design Schematic

By Abdul Majeed - September 29, 2012 1:11 pm

@avinash like proteus or any other To design Schematic. I want to test program without any hardware and in proteus GSM modem is notavailable.

By gaurav - October 1, 2012 10:50 am

Abdul,it is not possible to test program without any hardware.Thank you.

By Ravi - October 23, 2012 5:53 pm

Sir,where can i download sim300.h headder file

Can u please suggest any links for downloading the headder file…….

By Avinash - January 24, 2013 5:32 pm

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 36/52

replytocom=50150#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=50141#respond)

Purchase SIM300 kit with xBoard v2.0 from our store to get the files.

http://store.extremeelectronics.co.in/xBoard-v2.0.html(http://store.extremeelectronics.co.in/xBoard-v2.0.html)

http://store.extremeelectronics.co.in/GSM-GPRS-Modem-SIM300-KIT.html(http://store.extremeelectronics.co.in/GSM-GPRS-Modem-SIM300-KIT.html)

By Sumit Sinha - August 1, 2014 6:49 am

Sir, I am working with sim900 module and this code of sim300 is not working ontoit, as it does not give any response. Can you please tell me what necessarychanges should be made to work with sim900. Thanking You Sumit Sinha

By Avinash - August 1, 2014 11:16 am

@Sumit Sinha,

This code works perfectly on SIM900 also. You have having a messy hardware.To avoid wasting time (both yours and ours) and to do something magnificent(instead of dull days of disappointments ) please get a ready made hardware.We sell it for Rs. 4000 tell us if you are interested.

Thank you.

By Brijendra sangar - January 24, 2013 4:03 pm

•On SIM300 Initialization phase i get error “No Response” i have checked Rx,Tx and GND line connection between SIM300 and the Board. ? crystal frequency is 16MHz only. ?Fuse bits are set as said

i m using atmega 32A while using programer advantech labtooluxp i selected atmega32/L(there is only oneoption) i can’t get any pulse on crystall oscillator how i can move forward..plz help

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 37/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=50142#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=50151#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=50178#respond)

By Avinash - January 24, 2013 4:13 pm

Please run on xBoard v2.0 only http://store.extremeelectronics.co.in/xBoard-v2.0.html(http://store.extremeelectronics.co.in/xBoard-v2.0.html)

By Brijendra sangar - January 24, 2013 5:17 pm

my board is working proper i hve doubt of progarmmer…i m selectingatmega32/L instead of atmega 32

will it make any diffrence?

By Avinash - January 24, 2013 5:19 pm

Sorry if you are not interested in the solution, then you can have fun with yourtroubles. I am least interested to join your fun!

By Brijendra sangar - January 24, 2013 6:17 pm

i need full working project with all hardware and software . how much it will cost?

By Avinash - January 25, 2013 10:35 am

xBoard v2.0 @ Rs. 1264 http://store.extremeelectronics.co.in/xBoard-v2.0.html(http://store.extremeelectronics.co.in/xBoard-v2.0.html)

SIM300 KIT @ Rs. 1699 http://store.extremeelectronics.co.in/GSM-GPRS-Modem-SIM300-KIT.html

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 38/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=50854#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=50858#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=51143#respond)

http://store.extremeelectronics.co.in/GSM-GPRS-Modem-SIM300-KIT.html(http://store.extremeelectronics.co.in/GSM-GPRS-Modem-SIM300-KIT.html)

Shipping extra.

By kamran - February 12, 2013 12:26 am

Hello Mr.Avinash Thank you very much for your website. I have a question :

I am using SIM900 instead of SIM300.unfortunately i got “NO RESPONSE” responseand the microcontroller stops on this response and dont move further in. Is the problem with SIM900?it means that if i use SIM300 the problem will be solved?or the problem is on other part of circuit?i made the circuit exactly according to yourabove schematic on a breadboard.

Pleae advise me in this regard. Thanks and best.

By Avinash - February 12, 2013 9:51 am

@Kamran,

In your childhood you must have been taught time is money so you should notspend valuable time, please use exactly same hardware as shown to avoidproblems. Do not use breadboard for making circuit, use development boards asthe aim of the project is to learn GSM interfacing and NOT bread boarding.

By Amit - March 1, 2013 5:15 pm

Hello Mr.Avinash sir i am working on a project on gsm modem using atmega16 avr micro controller buti want to use gsm modem in auto-answering mode so when i call i will automaticallyreceive then call . i just want to know how i am going to do this or how can i programthe micro controller for this sir plz reply .

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 39/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=51468#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=51471#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=52104#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=52109#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=52464#respond)

By ronil - March 18, 2013 11:58 am

hey avinash i want to know what is the frame size we require for sending a messagefrom sim 300 that is gsm module …and where i can find total information about it..plz help

By Avinash - March 18, 2013 1:28 pm

@Ronil,

I could not understand your question.

By yogesh - April 3, 2013 3:54 am

Hello..!! I am using atmega16,sim300 module. internal crystal frequency is 8Mhz, and baud rate is also set accordingly , andconnections are also right, then also its showing “No Response ” on lcd.. Please help, am stuck on this from 1 week.. please do help..!!

thank you.!!

By Avinash - April 3, 2013 9:48 am

@ Yogesh

Use the same hardware as shown above to solve your problem.

By Praveen Attigeri - April 16, 2013 7:04 pm

how to connect zigbee and rfid both to single atmega 32 micro controller

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 40/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=52491#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=52779#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=53628#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=53220#respond)

how to connect zigbee and rfid both to single atmega 32 micro controller

By Avinash - April 17, 2013 10:59 am

@Praveen,

Use soft USART.

By mehran - April 23, 2013 6:07 pm

how i can buy SIM300 board ??

By rajesh - May 12, 2013 10:14 pm

online on this site

By ujjwal - May 2, 2013 4:29 pm

could you explain that while checking echo why u are comparing the length ofcommand AT with udataavaialble()

//Wait for echo while(i<10*len) { if(UDataAvailable()<len) { i++;

_delay_ms(10);

continue; } else {

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 41/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=53221#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=53223#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=53231#respond)

//We got an echo //Now check it UReadBuffer(sim300_buffer,len); //Read serial Data

return SIM300_OK; i am unable to understand this part

By Avinash - May 2, 2013 5:03 pm

@Ujjwal,

That’s because same number of bytes which are written to sim300 are echoed back

By ujjwal - May 2, 2013 5:10 pm

but 6 byte response will echo back and no of bytes written Is of only 3 bytes AT and

By Avinash - May 2, 2013 5:21 pm

Its task is to remove the echo only not the response. Response is checked latter.

By ujjwal - May 2, 2013 5:11 pm

CR

By ujjwal - May 2, 2013 8:07 pm

that means gsm sim300 woll always echo back the same command as it is sent to itand we just removing it means it is just one of function of sim300 to echo back just like other function as to send response,etc

have i understood correctly

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 42/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=53626#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=53246#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=53627#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?

replytocom=53625#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=56420#respond)

if yes thanks in advance

By rajesh - May 12, 2013 10:11 pm

yes u are right,in echo state as we give a single command(like A) there will beresponse from modem A. u can test this by communicating gsm modem by computer

By Nesrine - May 3, 2013 12:25 am

i’m fan of all your projects and interesting tutoriels on ExtremeElectronics website,could you please answer me how can i buy the SIM 300 moduel from india cause ihave no idea haw to do exactly in tunisia … , god bless you and thank you very muchMister Avinash.

By rajesh - May 12, 2013 10:12 pm

u can get online on extreme ele.site

By rajesh - May 12, 2013 10:05 pm

hello avinash sir, i have made this project and i want to add a extra hardware that is to display themessage send by mobile on led matrix . so pls sir guide me in writing program for it pls sir i need its my final year project pls reply me

By mahi - June 8, 2013 2:15 pm

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 43/52

replytocom=56420#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=56426#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=57137#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=57138#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=62367#respond)

Hello, I am using atmega8 for interfacing with the gsm module.I wrote the code in bascomand generated the hex file. I want to know the software required to dump the hexcode into the controller.can u please suggest a software for that.Is it possible to useother software such as hidbootflash for dumping?? Thank you

By Avinash - June 8, 2013 5:08 pm

@Mahi,

Please see this

http://extremeelectronics.co.in/xBoardMINI2/docs/Programming.htm(http://extremeelectronics.co.in/xBoardMINI2/docs/Programming.htm)

By Phyo - June 14, 2013 11:20 am

Sir, instead of using AVR dev board in connection sim300, can we use Arduino board?

By Avinash - June 14, 2013 11:38 am

Yes why NOT? You can use Arduino board, but then you get zero help from thispage this page doesn’t describe that !

By deepika - July 29, 2013 4:34 pm

Sir, Thank you very much for your website. I have a problem.. on flashing the file it shows -Mismatch at location 0×00000000 .what should i do??

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 44/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=62395#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=71369#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=73232#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=78758#respond)

what should i do?? please help.

By Avinash - July 29, 2013 6:17 pm

@Deepika,

more input is required from your side to get to any solution.

So it is suggested that you move this discussion to our forum.

http://forum.extremeelectronics.co.in/ (http://forum.extremeelectronics.co.in/)

By Ganesh - September 4, 2013 10:24 am

Hi sir, i am doing one project with sim 300 gsm module.here gsm module conecting to pcok.but is conected to microcontroller(pic16f88) is fails.micro controller sends the ATcommand and Gsm module sends “PU”.sir what the problem pls help me.

By VINOD - September 24, 2013 2:10 am

HELLO SIR I JUST WANT TO KNOW IF YOU HAVE MADE A SOFTWARE UART PROGRAM ORTUTORIAL AVAILABLE ON YOUR SITE FOR US TO LEARN ?, I HAVE SEARCHED YOUR SITEAND WAS NOT ABLE TO FIND ANYTHING RELATED SOFT UART. COULD U PLEASE HELPUS WITH SOFT UART,?

By Faizan Mehmood - December 9, 2013 4:10 pm

Kindly sir tell me what changes we have to run this code at sim900 gsm module. Kindly help me.

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 45/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=78770#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=80928#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=81894#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=84200#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=84720#respond)

By Avinash - December 10, 2013 9:29 am

@Faizan Mehmood.

From where have you purchased the SIM900?

By jothi sivaraj - February 11, 2014 10:46 am

hiii Mr.avinash, can u please help us with the GSM code for AVR controller…. we dnt have any ideaabt the programming and the header files…..

By gaurav - April 7, 2014 10:26 am

Hello Sir , I wants to upload any data coming from any serial port on sever (dropbox) by usingatmega16 and sim900 .and also read the response of sim900 . sir please can youhelp me.

By Ravindra kumar - July 2, 2014 10:46 pm

Hi Avinash, I am planning to purchase SIM900 kit from your website. Only thing I want to knowthat will the code for SIM300 will work for SIM900 or any change in Software orHardware is required?

By raj bista - July 25, 2014 8:40 pm

is this code is also compatible for sim 900 kit

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 46/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=87288#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=88146#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=89102#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=89167#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=89780#respond)

By ZsirosB - December 9, 2014 1:41 am

Hy All!

I want to interfacing a SIM900A module with an Atmega16 MCU. My question is quite simple: What does it mean ” we have implemented a interruptbased buffering of incoming data.” this bufffer is the MCU’s UART Buffer?

By sanket - January 9, 2015 4:50 pm

Implementation of SIM300Cmd, in this u have multiplied len by 10 so suppose mycommand is 7 bytes (inclusive of null char ) then total the loop may wait for 700msright?? so is there any logic beyond tym we have to wait for echo or is it simply 100tyms the bytes??

By Divisha - February 15, 2015 10:00 am

plzz provide all the three header files..usart.h, sim300.h, lcd.h i am unable to find it.

By Ayaz - February 17, 2015 11:23 am

Sir, you made embedded programming EASY … reading your tutorials are like being inadventure

By Krisha marathe - March 8, 2015 3:03 pm

I am getting “null” instead of “Test” in sending msg but in code its “Test” only Is this some sim problem??

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 47/52

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=89876#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=89901#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=93548#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=91739#respond)

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?replytocom=93528#respond)

Is this some sim problem??

By amal bhaskar - March 11, 2015 10:04 pm

sir we cant download sim300.h and usart.h file.i have successfully download lcd.hfile.please provide a link for downloading the header files.that must be more helpfulfor our project.

By Avinash - March 12, 2015 10:00 am

@Amal Bhaskar,

Yes sure we can help you by providing you all the files, but first you have to sharethis page on Facebook and send us the link to your Facebook profile.

By Peter - November 11, 2015 9:26 am

Hi, can you send me the sim300.h and usart.h file if you have it? plz send it to [email protected] (mailto:[email protected]) thank you

By Nick - May 24, 2015 2:12 pm

Is it possible to modify this code for using with gps modules?

By JYOTHIS - October 15, 2015 2:51 pm

hi Avinash

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 48/52

hi Avinash how do i interface sim 300 module and fingerprint module to the same xboard mini.is it possible? plz give some replay

Leave a Reply

Your email address will not be published. Required fields are marked *

6 × nine =

You may use these HTML (HyperText Markup Language) tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code><del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail

Post Comment

Name

Email

Website

Comment

Categories32bit ARM Projects (http://extremeelectronics.co.in/category/32bit-arm-projects/) (1)

AVR Development Board (http://extremeelectronics.co.in/category/avr-development-board/) (3)

AVR Projects (http://extremeelectronics.co.in/category/avr-projects/) (16)

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 49/52

Recent Articles

Recent Comments

AVR Projects (http://extremeelectronics.co.in/category/avr-projects/) (16)

AVR Tutorials (http://extremeelectronics.co.in/category/avr-tutorials/) (64)

Chitchat (http://extremeelectronics.co.in/category/chitchat/) (8)

Code Libraries (http://extremeelectronics.co.in/category/code-libraries/) (13)

Code Snippets (http://extremeelectronics.co.in/category/code-snippets/) (10)

Electronics (http://extremeelectronics.co.in/category/electronics/) (6)

GSM Projects (http://extremeelectronics.co.in/category/gsm-projects/) (2)

Hardwares (http://extremeelectronics.co.in/category/hardwares/) (8)

Microchip PIC Tutorials (http://extremeelectronics.co.in/category/microchip-pic-tutorials/) (17)

News (http://extremeelectronics.co.in/category/news/) (38)

PIC Development Board (http://extremeelectronics.co.in/category/pic-development-board/) (6)

PIC16F877A Tutorials (http://extremeelectronics.co.in/category/pic16f877a-tutorials/) (6)

Programming in 'C' (http://extremeelectronics.co.in/category/programming-in-c/) (1)

RF (http://extremeelectronics.co.in/category/rf/) (3)

Robotics (http://extremeelectronics.co.in/category/robotics/) (7)

Software (http://extremeelectronics.co.in/category/software/) (7)

Tools (http://extremeelectronics.co.in/category/tools/) (9)

Uncategorized (http://extremeelectronics.co.in/category/uncategorized/) (1)

Bluetooth Control of Home Appliances (http://extremeelectronics.co.in/news/bluetooth-control-of-home-appliances/)

Creating Your First Embedded Project in Atmel Studio (http://extremeelectronics.co.in/avr-tutorials/creating-your-first-embedded-project-in-atmel-studio/)

Development Process of Embedded Systems (http://extremeelectronics.co.in/avr-tutorials/development-process-of-embedded-systems/)

SMS Based Wireless Home Appliance Control System using PIC MCU(http://extremeelectronics.co.in/news/sms-based-wireless-home-appliance-control-system-using-pic-mcu/)

Interfacing HC-SR04 Ultrasonic Rangefinder with PIC 16F877A Microcontroller(http://extremeelectronics.co.in/news/interfacing-hc-sr04-ultrasonic-rangefinder-with-pic-16f877a-microcontroller/)

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 50/52

(https://www.mrosupply.com/)

(http://store.extremeelectronics.co.in/USB-AVR-Programmer-v2.1.html)

(http://store.extremeelectronics.co.in/28-PIN-AVR-Development-Board.html)

(http://store.extremeelectronics.co.in/40-PIN-AVR-Development-Board.html)

(http://store.extremeelectronics.co.in/xBoard-MINI-v2.0.html)

(http://store.extremeelectronics.co.in/xBoard-v2.0.html)

Facebook Like Box

sayed .skandar zamani (http://extremeelectronics.co.in/avr-projects/avr-project-%e2%80%93-atmega8-based-multi-channel-ir-remote/#comment-93604): hi please explained “remot.c &remot.h” Line by line thanks

begginerX (http://extremeelectronics.co.in/microchip-pic-tutorials/introduction-to-pic-interrupts-and-their-handling-in-c/#comment-93601): can u please send me the code for switch control led.

sunpyre (http://extremeelectronics.co.in/avr-tutorials/using-lcd-module-with-avrs/#comment-93598): Hi!! Just a question: how can i put an LCD DEM 16215 SYH-LY/V connected to a ATMEGA88,working with this...

pinkey (http://extremeelectronics.co.in/code-libraries/using-ir-remote-with-avr-mcus-part-ii/#comment-93597): hii sir… i’m using ATMEGA 8A CONTROLLER so i need a sample code for ir remotecontroller plz help...

adil (http://extremeelectronics.co.in/avr-tutorials/avr-timers-an-introduction/#comment-93596):please find my enqirey

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 51/52

DefaultersPraveen Mahato (http://extremeelectronics.co.in/defaulters/praveen_mahato.html)

Abhiram Guha (http://extremeelectronics.co.in/defaulters/ABHIRAM_GUHA.html)

Categories32bit ARM Projects(http://extremeelectronics.co.in/category/32bit-arm-projects/)AVR Development Board(http://extremeelectronics.co.in/category/avr-development-board/)AVR Projects(http://extremeelectronics.co.in/category/avr-projects/)AVR Tutorials(http://extremeelectronics.co.in/category/avr-tutorials/)Chitchat(http://extremeelectronics.co.in/category/chitchat/)Code Libraries(http://extremeelectronics.co.in/category/code-libraries/)

Code Snippets(http://extremeelectronics.co.in/category/code-snippets/)Electronics(http://extremeelectronics.co.in/category/electronics/)GSM Projects(http://extremeelectronics.co.in/category/gsm-projects/)Hardwares(http://extremeelectronics.co.in/category/hardwares/)Microchip PIC Tutorials(http://extremeelectronics.co.in/category/microchip-pic-tutorials/)News(http://extremeelectronics.co.in/category/news/)PIC Development Board

NavigationHome (http://extremeelectronics.co.in) Shop (http://shop.extremeelectronics.co.in) Links (http://extremeelectronics.co.in/links/)

SubscribeGet New Articles Deliverd To Your Inbox!

Email address:

Subscribe

Delivered by FeedBurner(http://www.feedburner.com)

(http://feeds2.feedburner.com/ExtremeElectronics)

MetaRegister (http://extremeelectronics.co.in/wp-login.php?action=register)Log in (http://extremeelectronics.co.in/wp-login.php)Entries RSS (Really Simple Syndication)(http://extremeelectronics.co.in/feed/)Comments RSS (Really Simple Syndication)(http://extremeelectronics.co.in/comments/feed/)WordPress.org (http://wordpress.org/)

12/22/2015 GSM Module SIM300 Interface with AVR Amega32 | eXtreme Electronics

http://extremeelectronics.co.in/avr­tutorials/gsm­module­sim300­interface­with­avr­amega32/ 52/52

PIC Development Board(http://extremeelectronics.co.in/category/pic-development-board/)PIC16F877A Tutorials(http://extremeelectronics.co.in/category/pic16f877a-tutorials/)Programming in 'C'(http://extremeelectronics.co.in/category/programming-in-c/)RF(http://extremeelectronics.co.in/category/rf/)Robotics(http://extremeelectronics.co.in/category/robotics/)Software(http://extremeelectronics.co.in/category/software/)Tools(http://extremeelectronics.co.in/category/tools/)Uncategorized(http://extremeelectronics.co.in/category/uncategorized/)

WordPress.org (http://wordpress.org/)

© 2015 eXtreme Electronics (http://extremeelectronics.co.in). All Rights Reserved.About (http://extremeelectronics.co.in/about-2/)Easy to follow tutorials on PIC and AVR microcontrollers, projects, codes, schematics, programming(http://extremeelectronics.co.in/home/)Links (http://extremeelectronics.co.in/links/)Privacy Policy (http://extremeelectronics.co.in/privacy-policy/)Welcome (http://extremeelectronics.co.in/welcome/)