Monday, 16 July 2018

Interface a GSM (SIM 300) Modem with AVR Microcontroller (Atmega8)

Aim:

GSM (Global System for Mobile Communication) technology lets user to communicate with others across mobile networks hence it offers a vast area of coverage. Interfacing GSM technology with microcontroller will enable us to extend the communication to cover large area. This tutorial will teach you about interfacing GSM module with atmega8 AVR microcontroller and program it to communicate it with another user.
F3FLJRGIDIN6G8Y.MEDIUM

Description:

STEP 1: MODEM TESTING:

The Modem consists of two indicating LED’s Green and Red to indicate the availability of the network. Green indicates the availability of the network whereas red indicates its absence. Turn the modem ON and wait for sometime to register itself in GSM network.

STEP 2: INTERFACING WITH AVR MICROCONTROLLER:

The Communication between AVR and modem takes place through USART protocol. GSM Modem SIM900 works on TTL level hence we can interface directly to RXD and TXD pins of AVR microcontroller. There is no need of using Voltage or level converter between them. However if you ever happen to buy a SIM300 or other module which operates above TTL level, you may want to use MAX232 level converter IC to make the communication possible.

STEP 3: INITIALIZING MODEM:

The modem must be Initialized using the commands and then the process you are about to carry out must be selected. In this tutorial am going to initialize the modem and them make it to send a message “Hi Raghav” to my mobile using the GSM modem.

Block Diagram

gsm

Schematic

gsm

Code

// *********************************************************
// Project: Interfacing GSM to atmega8 microcontroller
// Author: Hack Projects India
// Module description: Operate GSM
// *********************************************************
#include <avr/io.h>
#include <util/delay.h>
void USART_Init()
{
 UBRRL=0x33;
 UCSRB=(1<<TXEN)|(1<<RXEN);
 UCSRC=(3<<UCSZ0)|(1<<UMSEL);
}
unsigned char USART_Receave()
{
 while(!(UCSRA&(1<<RXC)));
 UCSRA=(0<<RXC);
 return UDR;
 _delay_ms(100);
}
void USART_Transmit(unsigned char data)
{
 UDR=data;
 while(!(UCSRA&(1<<TXC)));
 UCSRA=(0<<TXC);
 _delay_ms(100);
}
void Tx_String( char *str)
{
 while(*str)
 {
 USART_Transmit(*str);
 str++;
 _delay_ms(50);
 }
}
void Tx_Number(char *str)
{
 Tx_String("AT+CMGS=");
 USART_Transmit('"');
 while(*str)
 {
 USART_Transmit(*str);
 str++;
 _delay_ms(50);
 }
 USART_Transmit('"');
 USART_Transmit('\r');
 Tx_String("Hi Raghav");
 USART_Transmit('\r');
 USART_Transmit(0x1a);
}
int main(void)
{
 DDRC=0x00;
 DDRB=0xff;
 int j;
 USART_Init();
 Tx_Number("9999999999");
 While(1);                    
}         

Downloads:

The code was compiled in Atmel Studio 6 and simulation was made in Proteus v7.7.
To download code and proteus simulation click here.

Further Reading suggestions:

No comments:

Post a Comment