You are on page 1of 52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

(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/)

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

1/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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

This project can also be implemented using a PIC18F4520 microcontroller. We have


schematic 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 range
communication, like a robot in Chennai controlled by a person sitting in New Delhi! Or simply a
water pump in a rice field turned on in the morning by a farmer sitting in his house few
kilometers away! You have few communication options depending on the application, they may
be as follows.
Simple SMS based communication
Turn on/off loads using simple SMS commands, so the controlling device is a standard
handset. 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 on
his/her mobile via SMS.
Call based communication
A smart intruder alarm/fire alarm that calls the police or fire station and plays a pre
recorded 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 a
central control room to inform users or traffic conditions ahead.
A robot controlled over internet. That means the robot can be accessed from any device
having internet any where in the world.
A portable device installed on vehicles that connects to internet using the GPRS Module
SIM300 and uploads current position(using Global Position System) to a server. The server
stores those location in a database with the ID of vehicle. Then a client(using a PC) can
connect 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 a
fully integrated module with SIM card holder, power supply etc. This module can be easily
connected with low cost MCUs like AVR/PIC/8051. The basic communication is over asynchronous
serial line (http://extremeelectronics.co.in/avr-tutorials/rs232-communication-the-basics/). This
is the most basic type of serial communication thats why it is very popular and hardware
support is available in most MCUs. The data is transmitted bit by bit in a frame consisting a
complete byte. Thus at high level it is viewed as a simple text stream. Their are only two streams
one 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-

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

2/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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


Using the USART of AVR MCU Sending and Receiving data.
(http://extremeelectronics.co.in/avr-tutorials/using-the-usart-of-avr-microcontrollersreading-and-writing-data/)
If you have never heard of serial communication and never did it in practice then it is highly
recommend to go and understand clearly using some thing simpler (experiments given in above
links).

Communication with SIM300 Module using


AVR UART.
The hardware(inside the AVR MCU Chip) that is used to to serial communication is called the
UART, we use this UART to communicate with the SIM300 module (the UART can also be used to
communicate with other devices like RFID Readers, GPS Modules, Finger Print Scanner etc.). Since
UART is such a common method of communication in embedded world that we have made a
clean 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 busy
doing something else, then what happens? To solve this, we have implemented a interrupt based
buffering of incoming data. A buffer is maintained in the RAM of MCU to store all incoming
character. Their is a function to inquire about the number of bytes waiting in this queue.
Following are the functions in AVR USART library
voidUSARTInit(uint16_tubrrvalue)

Initializes the AVR USART Hardware. The parameter ubrrvalue is


required to set desired baud rate for communication. By default SIM300
communicates at 9600 bps. For an AVR MCU running at 16MHz the
ubrrvalue comes to be 103.

charUReadData()

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


available in the queue.

voidUWriteData(chardata)
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

3/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

voidUWriteData(chardata)

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


function.

uint8_tUDataAvailable()

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

voidUWriteString(char*str)

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


Example #1:
UWriteString("HelloWorld!");

Example #2:
charname[]="Avinash!";
UWriteString(name);

voidUReadBuffer(void*buff,uint16_tlen)

Copies the content of the fifo buffer to the memory pointed by buff, the
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

4/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

Copies the content of the fifo buffer to the memory pointed by buff, the
amount of data to be copied is specified by len parameter. If UART
incoming fifo buffer have fewer data than required (as per len
parameter) then latter areas will contain zeros.
Example:
chargsm_buffer[128];
UReadBuffer(gsm_buffer,16);

The above example will read 16 bytes of data (if available) from
the incoming fifo buffer to the variable gsm_buffer. Please note
that we have allocated gsm_buffer as 128 byte array because
latter we may need to read more than 16 bytes. So the same
buffer can be used latter to read data up to 128 bytes.
The above function is used generally along with UDataAvailable()
function.
while(UDataAvailable()<16)
{

//Donothing
}
chargsm_buffer[128];
UReadBuffer(gsm_buffer,16);

The above code snippet waits until we have 16 bytes of data


available in the buffer, then read all of them.

voidUFlushBuffer()

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

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

SIM300 AT Command Set


http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

5/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

SIM300 AT Command Set


Now you know the basics of AVR USART library and how to use it to initialize the USART, send
and receive character data, its time for us to move ahead and look what commands are
available with SIM300 module and how we issue commands and check the response. SIM300
supports several functions like sending text messages, making phone call etc. Each of the tasks is
done 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> in
short). The ASCII code of CR is 0x0D (decimal 13). Anything you write to SIM300 will be echoed
back from sim300s tx line. That means if you write a command which is 7 bytes long (including
the trailing CR) then immediately you will have same 7 bytes in the MCUs UART incoming buffer.
If you dont 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 and
constants 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 in
sim300.h). If we have waited too long and echo didnt arrive then it returns SIM300_TIMEOUT.
Implementation of SIM300Cmd()

int8_tSIM300Cmd(constchar*cmd)
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

6/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

int8_tSIM300Cmd(constchar*cmd)
{
UWriteString(cmd);//SendCommand
UWriteData(0x0D);//CR
uint8_tlen=strlen(cmd);
len++;//Add1fortrailingCRaddedtoallcommands
uint16_ti=0;
//Waitforecho
while(i<10*len)
{
if(UDataAvailable()<len)
{
i++;
_delay_ms(10);
continue;
}
else
{
//Wegotanecho
//Nowcheckit
UReadBuffer(sim300_buffer,len);//ReadserialData
returnSIM300_OK;
}
}
returnSIM300_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 while
waiting for a response :
No response is received after waiting for a long time, reason can be that the SIM300 is not
connected properly with the MCU.
Response is received but not as expected, reason can be faulty serial line or incorrent baud
rate 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 :-

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

7/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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 wait
until we have received 20 bytes of data or certain amount of time has elapsed. The second
condition 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 is
taking too long to respond (this condition is called timeout)
If correct response is received we analyses variable <stat> to get the current network
registration.
depending on current network registration status the value of stat can be
0
1
2
3
4
5

not registered, SIM300 is not currently searching a new operator to register to


registered, home network
not registered, but SIM300 is currently searching a new operator to register to
registration denied
unknown
registered, roaming

Implementation of SIM300GetNetStat() Function

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

8/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

int8_tSIM300GetNetStat()
{
//SendCommand
SIM300Cmd("AT+CREG?");
//Nowwaitforresponse
uint16_ti=0;
//correctresponseis20bytelong
//Sowaituntilwehavegot20bytes
//inbuffer.
while(i<10)
{
if(UDataAvailable()<20)
{
i++;
_delay_ms(10);
continue;
}
else
{
//Wegotaresponsethatis20byteslong
//Nowcheckit
UReadBuffer(sim300_buffer,20);//ReadserialData
if(sim300_buffer[11]=='1')
returnSIM300_NW_REGISTERED_HOME;
elseif(sim300_buffer[11]=='2')
returnSIM300_NW_SEARCHING;
elseif(sim300_buffer[11]=='5')
returnSIM300_NW_REGISTED_ROAMING;
else
returnSIM300_NW_ERROR;
}
}
//Wewaitedsolongbutgotnoresponse
//Sotellcallerthatwetimedout
returnSIM300_TIMEOUT;
}

Similarly we have implemented the following functions :int8_t SIM300IsSIMInserted()


In another type of response we dont exactly know the size of response like we knew for the
above command. Example is the Get Service Provider Name command where the provider names
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

9/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

above command. Example is the Get Service Provider Name command where the provider names
length cannot be known in advance. It can be Airtel or Reliance or TATA Docomo. To handle that
situation we make use of the fact that all response are followed by a CR LF pair. So we simple
buffer in all characters until we encounter a CR, that indicates end of response.
To simplify handling of such commands we have made a function called
SIM300WaitForResponse(uint16_t timeout)
This function waits for a response from SIM300 module (end of response is indicated by a CR), it
returns the size if response received, while the actual response is copied to the global variable
sim300_buffer[].
If no response is received before timeout it returns 0. Timeout in millisecond can be specified by
the parameter timeout. It does not count the trailing LF or the last <CR><LF>OK<CR><LF>, they
remain in the UART fifo queue. So before returning we call UFlushBuffer() to remove those from
the queue.
Implementation of function SIM300WaitForResponse(uint16_t timeout)

int8_tSIM300WaitForResponse(uint16_ttimeout)
{
uint8_ti=0;
uint16_tn=0;
while(1)
{
while(UDataAvailable()==0&&n<timeout){n++;_delay_ms(1);}
if(n==timeout)
return0;
else
{
sim300_buffer[i]=UReadData();
if(sim300_buffer[i]==0x0D&&i!=0)
returni+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 or
errors.
2. It send the command "AT+CSPN?" using SIM300Cmd("AT+CSPN?"); function call.

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

10/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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_tSIM300GetProviderName(char*name)
{
UFlushBuffer();
//SendCommand
SIM300Cmd("AT+CSPN?");
uint8_tlen=SIM300WaitForResponse(1000);
if(len==0)
returnSIM300_TIMEOUT;
char*start,*end;
start=strchr(sim300_buffer,'"');
start++;
end=strchr(start,'"');
*end='\0';
strcpy(name,start);
returnstrlen(name);
}

SIM300 and ATmega32 Hardware Setup


NOTE: To learn AVR Microcontrollers and do hands on
experiments at home you can purchase xBoard. It is a
low cost development board designed to get started
with minimum efforts and to easily perform common
tasks. Lots of sample programs helps you easily
complete projects. It is a must have tool if you want to
do something real and instead of just wasting time just
trying to achieve basic things and avoid problems that
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

11/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

trying to achieve basic things and avoid problems that


dont 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 ! 15
Days Money Back!

To run the basic demo showing communication with SIM300 using AVR ATmega32 we need the
following 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 162 Alphanumeric LCD Module (http://extremeelectronics.co.in/avr-tutorials/using-lcdmodule-with-avrs/) to show programs output.
SIM300 Module (http://store.extremeelectronics.co.in/GSM-GPRS-Modem-SIM300-KIT.html).

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

12/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

(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/xBoardv2.0.html) development board because it has ATmega32 core circuit, 5v power supply circuit and
the LCD module.

Fig. SIM300 and ATmega32 Connection

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

13/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

Fig. SIM300s PINs

Fig. xBoards USART PINs

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

14/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

Fig. GSM Module connected with ATmega32

NOTE
The 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 be
used to make this project. New version is much smaller and low cost.

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

15/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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

Fig. SIM300 Module New Version

Demo Source Code for AVR and SIM300


Interface
The demo source code is written in C language and compiled using free avr-gcc compiler using
the latest Atmel Studio 6 IDE. The project is split into the following modules.
LCD Library
Files lcd.c, lcd.h, myutils.h, custom_char.h
Job is to control standard 162 LCD Module.
More information on LCD library.
(http://xboard.extremeelectronics.co.in/Name_In_LCD.htm)
USART Library
Files usart.c,usart.h
Job is to control the USART hardware of AVR MCU. Includes functions to initialize the
USART, Send/Receive chars, Send/Receive Strings.
SIM300 Library
Files sim300.c, sim300.h
To build the project you need to be have working knowledge of the Atmel Studio 6 IDE. Please
refer to the following tutorial.

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

16/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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 folder
named "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.h
copy followings files to the usart folder (using Windows File Manager) usart.c,usart.h
copy followings files to the sim300 folder (using Windows File Manager sim300.c, sim300.h
Add 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=16000000
using AS6s
in 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 HIGH
FUSE are 0xC9.

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

17/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

Fig.: Setting the Fuse bytes.

/*
*Sim300Demo.c
*
*Created:10072012PM12:23:08
*Author:Avinash

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

18/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

*Author:Avinash
*/

#include<avr/io.h>
#include<util/delay.h>
#include"lib/lcd/lcd.h"
#include"lib/sim300/sim300.h"

voidHalt();
intmain(void)
{
//InitializeLCDModule
LCDInit(LS_NONE);
//IntroMessage
LCDWriteString("SIM300Demo!");
LCDWriteStringXY(0,1,"ByAvinashGupta");
_delay_ms(1000);
LCDClear();

//InitializeSIM300module
LCDWriteString("Initializing...");
int8_tr=SIM300Init();
_delay_ms(1000);
//Checkthestatusofinitialization
switch(r)
{
caseSIM300_OK:
LCDWriteStringXY(0,1,"OK!");
break;
caseSIM300_TIMEOUT:
LCDWriteStringXY(0,1,"Noresponse");
Halt();
caseSIM300_INVALID_RESPONSE:
LCDWriteStringXY(0,1,"Invresponse");
Halt();
caseSIM300_FAIL:
LCDWriteStringXY(0,1,"Fail");
Halt();
default:
LCDWriteStringXY(0,1,"UnknownError");
Halt();
}

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

19/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

_delay_ms(1000);
//IMEINodisplay
LCDClear();
charimei[16];
r=SIM300GetIMEI(imei);
if(r==SIM300_TIMEOUT)
{
LCDWriteString("CommError!");
Halt();
}
LCDWriteString("DeviceIMEI:");
LCDWriteStringXY(0,1,imei);
_delay_ms(1000);
//ManufacturerID
LCDClear();
charman_id[48];
r=SIM300GetManufacturer(man_id);
if(r==SIM300_TIMEOUT)
{
LCDWriteString("CommError!");
Halt();
}
LCDWriteString("Manufacturer:");
LCDWriteStringXY(0,1,man_id);
_delay_ms(1000);
//ManufacturerID
LCDClear();
charmodel[48];
r=SIM300GetModel(model);
if(r==SIM300_TIMEOUT)
{
LCDWriteString("CommError!");
Halt();
}

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

20/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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

//CheckSimCardPresence
LCDClear();
LCDWriteString("CheckingSIMCard");
_delay_ms(1000);
r=SIM300IsSIMInserted();
if(r==SIM300_SIM_NOT_PRESENT)
{
//SimcardisNOTpresent
LCDWriteStringXY(0,1,"NoSIMCard!");
Halt();
}
elseif(r==SIM300_TIMEOUT)
{
//CommunicationError
LCDWriteStringXY(0,1,"CommError!");
Halt();
}
elseif(r==SIM300_SIM_PRESENT)
{
//Simcardpresent
LCDWriteStringXY(0,1,"SIMCardPresent");
_delay_ms(1000);
}
//Networksearch
LCDClear();
LCDWriteStringXY(0,0,"SearchingNetwork");
uint8_tnw_found=0;
uint16_ttries=0;
uint8_tx=0;
while(!nw_found)
{
r=SIM300GetNetStat();
if(r==SIM300_NW_SEARCHING)
{

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

21/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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("NetworkFound");
}
else
{
LCDWriteString("CantConnttoNW!");
Halt();
}
_delay_ms(1000);
LCDClear();
//ShowProviderName
charpname[32];
r=SIM300GetProviderName(pname);
if(r==0)
{
LCDWriteString("CommError!");
Halt();
}
LCDWriteString(pname);
_delay_ms(1000);
Halt();
}

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

22/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

voidHalt()
{
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 ID
Then checks for the SIM card presence.
Searches for a GSM Network and establishes a connection. The sim card need to be valid in
order to connect to the GSM network.
Shows the Network Providers name like Airtel or Vodafone.

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

23/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

AndroidSmartphoneControlledHomeAppliances! WatchNow
(http://extremeelectronics.co.in/wpcontent/plugins/ad_band/click.php?id=2)

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

24/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

25/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

26/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

Troubleshooting
NO 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 Errors
1. Many people these days has jumped to embedded programming without a solid concept
of computer science and programming. They dont know the basics of compiler and lack
experience. To learn basic of compilers and their working PC/MAC/Linux( I mean a
desktop or laptop) are great platform. But embedded system is not good for learning
about compilers and programming basics. It is for those who already have these skills
and 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/DevelopmentBoards/) and programmers (http://store.extremeelectronics.co.in/Programmers/).
Try to follow the AVR Tutorial Series (http://extremeelectronics.co.in/category/avrtutorials/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.

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

27/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

(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/avrtutorials/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 we
can. If you like these tutorials and they have helped you solve problems, please help us in
return. 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.


By
Avinash Gupta
Facebook (http://www.facebook.com/profile.php?id=100000536005502), Follow on Twitter
(http://twitter.com/eXtremeElec).
www.AvinashGupta.com (http://www.AvinashGupta.com)
me@avinashgupta.com (mailto:me@avinashgupta.com)

Avinash
(http://extremeelectronics.co.in/author/Avinash/
Avinash Gupta is solely focused on free and high quality tutorial to make learning
embedded 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)

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

28/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

Line Following Robot using AVR ATmega8 ...

Sending and Receiving SMS using SIM300 GS...

86 thoughts on GSM Module SIM300 Interface


with AVR Amega32
By Binu - July 29, 2012 1:31 pm
Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=42803#respond)
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 show
the imei number on web.

By alemt - July 30, 2012 3:15 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=42821#respond)
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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=42824#respond)
Niceplease add the tutorial for GPS.

By Murali - July 30, 2012 6:44 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=42826#respond)
Thanks for one more great article.

By Avinash - July 30, 2012 6:46 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=42827#respond)
Thanks you liked it !

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

29/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

Pingback: Sending an Receiving SMS using SIM300 GSM Module | eXtreme Electronics
(http://extremeelectronics.co.in/avr-tutorials/sending-an-receiving-sms-using-sim300-gsmmodule/)
By Gangster - August 22, 2012 9:26 am
Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=43413#respond)
Hi avinash really awesum tutorialsman.!!
i m working on AVR microcontrollers. I used various development board but really
those boards needs to be upgraded so i m plaining to designed my own
development 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 extremeelectronics
style.
i m totally impressed the way u explain things.. just waiting for tutorial on this
topic 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
Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=43589#respond)
Hello
Nice TutorialI am working on GSM Modem SIm300 with 8051 Micro.
When i got message NO DIAL TONE from modem, Micro gets hanged up.I tried reset
Command 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 to
solve it without using delay.

One problem arises. When i made a call to only one number again and again, it
works properly. But when i call to two numbers one after the other in a loop, it works
only 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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

30/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=43877#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 really
very helpful.
With best wishes

By Avinash - September 10, 2012 11:03 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=43880#respond)
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 dont have the time to list.

By abhilash - September 13, 2012 10:10 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=43937#respond)
Hi Avinash,
you are a killer man.you are just fantastic thnx a ton or this amazing tutorials.this thing
was not so easy before.you are amzinghats off:)
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

31/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

was not so easy before.you are amzinghats off:)

By Avinash - September 14, 2012 11:42 am


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

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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=44109#respond)
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 pls
tell me how to use it.

By Gangster - September 20, 2012 1:06 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=44111#respond)
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 to
use Atmega32 with software USART. Thank
you.

By gaurav - September 20, 2012 1:16 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=44112#respond)
Yes Parminder, it is certainly possible to connect one RF ID and one GSM modem
with 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 and
another one with software USART.A soft USART library helps in connecting more

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

32/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

another one with software USART.A soft USART library helps in connecting more
than one
serial devices to a MCU which only has a single hardware USART. For example you
may connect a GSM Module and GPS Module at the same time to a low cost MCU
like
ATmega8. Otherwise you have to look for a MCU which has two serial ports, but
that will be a costly option. So this library helps you emmulate a second software
serial
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 get
this 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 one
Atmega32.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 the
complexity
Parminder bro i still suggest atmega324rest up to u.

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


Thanks brother. I will try to do this.

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

33/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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 100
units. That will save you Rs. 20000/- ! (considering Rs 200 over head on each
product).
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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=44150#respond)
@avinash
well i thought he was planing to make a single piece and to hire a developer and
give 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 thats why pointed him a
professional 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 the
field, he may face similar situation atleast twice ! What do you say ?

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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=44360#respond)
@avinash
Which design software do you use?

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

34/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

By Avinash - September 29, 2012 1:01 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=44361#respond)
@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 not
available.

By gaurav - October 1, 2012 10:50 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=44400#respond)
Abdul,it is not possible to test program without any hardware.Thank you.

By Ravi - October 23, 2012 5:53 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=44995#respond)
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


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

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

35/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

replytocom=50150#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 onto
it, as it does not give any response. Can you please tell me what necessary
changes 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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=50141#respond)
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 one
option)
i cant get any pulse on crystall oscillator
how i can move forward..plz help

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

36/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

By Avinash - January 24, 2013 4:13 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=50142#respond)
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 progarmmeri m selecting
atmega32/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 your
troubles. I am least interested to join your fun!

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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=50151#respond)
i need full working project with all hardware and software . how much it will cost?

By Avinash - January 25, 2013 10:35 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=50178#respond)
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
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

37/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=50854#respond)
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 response
and 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 your
above schematic on a breadboard.
Pleae advise me in this regard.
Thanks and best.

By Avinash - February 12, 2013 9:51 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=50858#respond)
@Kamran,
In your childhood you must have been taught time is money so you should not
spend valuable time, please use exactly same hardware as shown to avoid
problems. Do not use breadboard for making circuit, use development boards as
the aim of the project is to learn GSM interfacing and NOT bread boarding.

By Amit - March 1, 2013 5:15 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=51143#respond)
Hello Mr.Avinash
sir i am working on a project on gsm modem using atmega16 avr micro controller but
i want to use gsm modem in auto-answering mode so when i call i will automatically
receive then call . i just want to know how i am going to do this or how can i program
the micro controller for this sir plz reply .

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

38/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

By ronil - March 18, 2013 11:58 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=51468#respond)
hey avinash i want to know what is the frame size we require for sending a message
from 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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=51471#respond)
@Ronil,
I could not understand your question.

By yogesh - April 3, 2013 3:54 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=52104#respond)
Hello..!!
I am using atmega16,sim300 module.
internal crystal frequency is 8Mhz, and baud rate is also set accordingly , and
connections 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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=52109#respond)
@ Yogesh
Use the same hardware as shown above to solve your problem.

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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=52464#respond)
how to connect zigbee and rfid both to single atmega 32 micro controller

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

39/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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

By Avinash - April 17, 2013 10:59 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=52491#respond)
@Praveen,
Use soft USART.

By mehran - April 23, 2013 6:07 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=52779#respond)
how i can buy SIM300 board ??

By rajesh - May 12, 2013 10:14 pm


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

By ujjwal - May 2, 2013 4:29 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=53220#respond)
could you explain that while checking echo why u are comparing the length of
command AT with udataavaialble()

//Wait for echo


while(i<10*len)
{
if(UDataAvailable()<len)
{
i++;
_delay_ms(10);
continue;
}
else
{

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

40/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

//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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=53221#respond)
@Ujjwal,
Thats 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


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

By ujjwal - May 2, 2013 8:07 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=53231#respond)
that means gsm sim300 woll always echo back the same command as it is sent to it
and 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

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

41/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

if yes thanks in advance

By rajesh - May 12, 2013 10:11 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=53626#respond)
yes u are right,in echo state as we give a single command(like A) there will be
response from modem A.
u can test this by communicating gsm modem by computer

By Nesrine - May 3, 2013 12:25 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=53246#respond)
im fan of all your projects and interesting tutoriels on ExtremeElectronics web
site,could you please answer me how can i buy the SIM 300 moduel from india cause i
have no idea haw to do exactly in tunisia , god bless you and thank you very much
Mister Avinash.

By rajesh - May 12, 2013 10:12 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=53627#respond)
u can get online on extreme ele.site

By rajesh - May 12, 2013 10:05 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=53625#respond)
hello avinash sir,
i have made this project and i want to add a extra hardware that is to display the
message 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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=56420#respond)
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

42/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

replytocom=56420#respond)
Hello,
I am using atmega8 for interfacing with the gsm module.I wrote the code in bascom
and generated the hex file. I want to know the software required to dump the hex
code into the controller.can u please suggest a software for that.Is it possible to use
other software such as hidbootflash for dumping??
Thank you

By Avinash - June 8, 2013 5:08 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=56426#respond)
@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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=57137#respond)
Sir, instead of using AVR dev board in connection sim300, can we use Arduino board?

By Avinash - June 14, 2013 11:38 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=57138#respond)
Yes why NOT? You can use Arduino board, but then you get zero help from this
page this page doesnt describe that !

By deepika - July 29, 2013 4:34 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=62367#respond)
Sir,
Thank you very much for your website.
I have a problem..
on flashing the file it shows -Mismatch at location 000000000 .
what should i do??

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

43/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

what should i do??


please help.

By Avinash - July 29, 2013 6:17 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=62395#respond)
@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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=71369#respond)
Hi sir,
i am doing one project with sim 300 gsm module.here gsm module conecting to pc
ok.but is conected to microcontroller(pic16f88) is fails.micro controller sends the AT
command and Gsm module sends PU.sir what the problem pls help me.

By VINOD - September 24, 2013 2:10 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=73232#respond)
HELLO SIR
I JUST WANT TO KNOW IF YOU HAVE MADE A SOFTWARE UART PROGRAM OR
TUTORIAL AVAILABLE ON YOUR SITE FOR US TO LEARN ?, I HAVE SEARCHED YOUR SITE
AND WAS NOT ABLE TO FIND ANYTHING RELATED SOFT UART. COULD U PLEASE HELP
US WITH SOFT UART,?

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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=78758#respond)
Kindly sir tell me what changes we have to run this code at sim900 gsm module.
Kindly help me.

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

44/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

By Avinash - December 10, 2013 9:29 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=78770#respond)
@Faizan Mehmood.
From where have you purchased the SIM900?

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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=80928#respond)
hiii Mr.avinash,
can u please help us with the GSM code for AVR controller. we dnt have any idea
abt the programming and the header files..

By gaurav - April 7, 2014 10:26 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=81894#respond)
Hello Sir ,
I wants to upload any data coming from any serial port on sever (dropbox) by using
atmega16 and sim900 .and also read the response of sim900 . sir please can you
help me.

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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=84200#respond)
Hi Avinash,
I am planning to purchase SIM900 kit from your website. Only thing I want to know
that will the code for SIM300 will work for SIM900 or any change in Software or
Hardware is required?

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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=84720#respond)
is this code is also compatible for sim 900 kit

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

45/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

By ZsirosB - December 9, 2014 1:41 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=87288#respond)
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 interrupt
based buffering of incoming data.
this bufffer is the MCUs UART Buffer?

By sanket - January 9, 2015 4:50 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=88146#respond)
Implementation of SIM300Cmd, in this u have multiplied len by 10 so suppose my
command is 7 bytes (inclusive of null char ) then total the loop may wait for 700ms
right?? so is there any logic beyond tym we have to wait for echo or is it simply 100
tyms the bytes??

By Divisha - February 15, 2015 10:00 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=89102#respond)
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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=89167#respond)
Sir,
you made embedded programming EASY reading your tutorials are like being in
adventure

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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=89780#respond)
I am getting null instead of Test in sending msg
but in code its Test only
Is this some sim problem??
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

46/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

Is this some sim problem??

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


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=89876#respond)
sir we cant download sim300.h and usart.h file.i have successfully download lcd.h
file.please provide a link for downloading the header files.that must be more helpful
for our project.

By Avinash - March 12, 2015 10:00 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=89901#respond)
@Amal Bhaskar,
Yes sure we can help you by providing you all the files, but first you have to share
this page on Facebook and send us the link to your Facebook profile.

By Peter - November 11, 2015 9:26 am


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=93548#respond)
Hi, can you send me the sim300.h and usart.h file if you have it?
plz send it to phantom_0323@yahoo.com (mailto:phantom_0323@yahoo.com)
thank you

By Nick - May 24, 2015 2:12 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=91739#respond)
Is it possible to modify this code for using with gps modules?

By JYOTHIS - October 15, 2015 2:51 pm


Reply (/avr-tutorials/gsm-module-sim300-interface-with-avr-amega32/?
replytocom=93528#respond)
hi Avinash
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

47/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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 *

Name
Email
Website

6 nine =
Comment

You may use these HTML (HyperText Markup Language) tags and attributes:
<ahref=""title=""><abbrtitle=""><acronymtitle=""><b><blockquotecite=""><cite><code>
<deldatetime=""><em><i><qcite=""><strike><strong>

Notify me of followup comments via e-mail

Post Comment

Categories
32bit 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)
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

48/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

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)

Recent Articles
Bluetooth Control of Home Appliances (http://extremeelectronics.co.in/news/bluetooth-control-ofhome-appliances/)
Creating Your First Embedded Project in Atmel Studio (http://extremeelectronics.co.in/avrtutorials/creating-your-first-embedded-project-in-atmel-studio/)
Development Process of Embedded Systems (http://extremeelectronics.co.in/avrtutorials/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-usingpic-mcu/)
Interfacing HC-SR04 Ultrasonic Rangefinder with PIC 16F877A Microcontroller
(http://extremeelectronics.co.in/news/interfacing-hc-sr04-ultrasonic-rangefinder-with-pic-16f877amicrocontroller/)

Recent Comments
http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

49/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

sayed .skandar zamani (http://extremeelectronics.co.in/avr-projects/avr-project-%e2%80%93atmega8-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-interruptsand-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/#comment93598): 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-partii/#comment-93597): hii sir im using ATMEGA 8A CONTROLLER so i need a sample code for ir remote
controller plz help...
adil (http://extremeelectronics.co.in/avr-tutorials/avr-timers-an-introduction/#comment-93596):
please find my enqirey
(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

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

50/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

Defaulters
Praveen Mahato (http://extremeelectronics.co.in/defaulters/praveen_mahato.html)
Abhiram Guha (http://extremeelectronics.co.in/defaulters/ABHIRAM_GUHA.html)

Categories

Navigation

32bit ARM Projects


Home (http://extremeelectronics.co.in)
(http://extremeelectronics.co.in/category/32bit- Shop (http://shop.extremeelectronics.co.in)
arm-projects/)
Links (http://extremeelectronics.co.in/links/)
AVR Development Board
(http://extremeelectronics.co.in/category/avrdevelopment-board/)
AVR Projects
Get New Articles Deliverd To Your Inbox!
(http://extremeelectronics.co.in/category/avrEmail address:
projects/)
AVR Tutorials
(http://extremeelectronics.co.in/category/avrtutorials/)
Subscribe
Chitchat
Delivered by FeedBurner
(http://extremeelectronics.co.in/category/chitchat/)
(http://www.feedburner.com)
Code Libraries
(http://extremeelectronics.co.in/category/codelibraries/)

Subscribe

Code Snippets
(http://extremeelectronics.co.in/category/code- (http://feeds2.feedburner.com/ExtremeElectronics)
snippets/)
Electronics
(http://extremeelectronics.co.in/category/electronics/)
GSM Projects
(http://extremeelectronics.co.in/category/gsmRegister (http://extremeelectronics.co.in/wpprojects/)
login.php?action=register)
Hardwares
Log in (http://extremeelectronics.co.in/wp(http://extremeelectronics.co.in/category/hardwares/)
login.php)
Microchip PIC Tutorials
Entries RSS (Really Simple Syndication)
(http://extremeelectronics.co.in/category/microchip(http://extremeelectronics.co.in/feed/)
pic-tutorials/)
Comments RSS (Really Simple Syndication)
News
(http://extremeelectronics.co.in/comments/feed/)
(http://extremeelectronics.co.in/category/news/)
WordPress.org (http://wordpress.org/)
PIC Development Board

Meta

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

51/52

12/22/2015

GSMModuleSIM300InterfacewithAVRAmega32|eXtremeElectronics

WordPress.org (http://wordpress.org/)
PIC Development Board
(http://extremeelectronics.co.in/category/picdevelopment-board/)
PIC16F877A Tutorials
(http://extremeelectronics.co.in/category/pic16f877atutorials/)
Programming in 'C'
(http://extremeelectronics.co.in/category/programmingin-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/)

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/)

http://extremeelectronics.co.in/avrtutorials/gsmmodulesim300interfacewithavramega32/

52/52

You might also like