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 8051 microcontroller
and program it to communicate it with another user.
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 8051 microcontroller
and program it to communicate it with another user.
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.
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 8051 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.
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 8051 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.
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
Schematic
Code
// *********************************************************
// Project: Interfacing GSM to 8051 microcontroller
// Author: Code Bloges
// Module description: Operate GSM
// *********************************************************
#include <reg52.h>
//DEFINE CONSTANT
#define Baud_rate 0xFD // BAUD RATE 9600
//DEFINE PROTOTYPES
void USART_Init(void);
void USART_Transmit(unsigned char);
void cct_init(void);
void delay(unsigned int t);
void Tx_String( char *str);
void Number( char *str);
void main()
{
cct_init();
USART_Init();
Number("9999999999");
while(1);
}
void Number( char *str)
{
Tx_String("AT");
USART_Transmit('\r');
delay(1000);
Tx_String("AT+CMGF=1");
USART_Transmit('\r');
delay(1000);
Tx_String("AT+CMGS=");
USART_Transmit('"');
while(*str)
{
USART_Transmit(*str);
str++;
delay(200);
}
USART_Transmit('"');
USART_Transmit('\r');
delay(1000);
Tx_String("Hi Raghav");
delay(1000);
USART_Transmit(0x1a);
}
void delay(unsigned int t)
{
unsigned int i,j;
for(i=0;i<t;i++)
{
for(j=0;j<50;j++);
}
}
void cct_init(void) //initialize cct
{
P0 = 0x00; //not used
P1 = 0x00; //Used for Appliances
P2 = 0x00; //not used
P3 = 0x03; //used for serial
}
void USART_Init(void) // INITIALIZE SERIAL PORT
{
TMOD = 0x20; // Timer 1 IN MODE 2 -AUTO RELOAD TO GENERATE BAUD RATE
SCON = 0x50; // SERIAL MODE 1, 8-DATA BIT 1-START BIT, 1-STOP BIT, REN ENABLED
TH1 = Baud_rate; // LOAD BAUDRATE TO TIMER REGISTER
TR1 = 1; // START TIMER
}
void USART_Transmit(unsigned char serialdata)
{
SBUF = serialdata; // LOAD DATA TO SERIAL BUFFER REGISTER
while(TI == 0); // WAIT UNTIL TRANSMISSION TO COMPLETE
TI = 0; // CLEAR TRANSMISSION INTERRUPT FLAG
}
void Tx_String( char *str)
{
while(*str)
{
USART_Transmit(*str);
str++;
delay(200);
}
}
// ********************************************************* // Project: Interfacing GSM to 8051 microcontroller // Author: Code Bloges // Module description: Operate GSM // ********************************************************* #include <reg52.h> //DEFINE CONSTANT #define Baud_rate 0xFD // BAUD RATE 9600 //DEFINE PROTOTYPES void USART_Init(void); void USART_Transmit(unsigned char); void cct_init(void); void delay(unsigned int t); void Tx_String( char *str); void Number( char *str); void main() { cct_init(); USART_Init(); Number("9999999999"); while(1); } void Number( char *str) { Tx_String("AT"); USART_Transmit('\r'); delay(1000); Tx_String("AT+CMGF=1"); USART_Transmit('\r'); delay(1000); Tx_String("AT+CMGS="); USART_Transmit('"'); while(*str) { USART_Transmit(*str); str++; delay(200); } USART_Transmit('"'); USART_Transmit('\r'); delay(1000); Tx_String("Hi Raghav"); delay(1000); USART_Transmit(0x1a); } void delay(unsigned int t) { unsigned int i,j; for(i=0;i<t;i++) { for(j=0;j<50;j++); } } void cct_init(void) //initialize cct { P0 = 0x00; //not used P1 = 0x00; //Used for Appliances P2 = 0x00; //not used P3 = 0x03; //used for serial } void USART_Init(void) // INITIALIZE SERIAL PORT { TMOD = 0x20; // Timer 1 IN MODE 2 -AUTO RELOAD TO GENERATE BAUD RATE SCON = 0x50; // SERIAL MODE 1, 8-DATA BIT 1-START BIT, 1-STOP BIT, REN ENABLED TH1 = Baud_rate; // LOAD BAUDRATE TO TIMER REGISTER TR1 = 1; // START TIMER } void USART_Transmit(unsigned char serialdata) { SBUF = serialdata; // LOAD DATA TO SERIAL BUFFER REGISTER while(TI == 0); // WAIT UNTIL TRANSMISSION TO COMPLETE TI = 0; // CLEAR TRANSMISSION INTERRUPT FLAG } void Tx_String( char *str) { while(*str) { USART_Transmit(*str); str++; delay(200); } }
Further Reading suggestions:
You may also like,
- Interfacing keypad with 8051
- Interfacing with UART of 8051 controller
- Interfacing SPI communication with 8051
- 8051 Displaying Custom Characters on LCD
- 8051 Graphical LCD
- RTC interfacing using I2C in 8051
- Interfacing ultrasonic sensor with 8051
- Interfacing GPS Modu with 8051
- ADC Module interfacing with 8051
- Interfacing PWM in 8051
- Interfacing keypad with 8051
- Interfacing with UART of 8051 controller
- Interfacing SPI communication with 8051
- 8051 Displaying Custom Characters on LCD
- 8051 Graphical LCD
- RTC interfacing using I2C in 8051
- Interfacing ultrasonic sensor with 8051
- Interfacing GPS Modu with 8051
- ADC Module interfacing with 8051
- Interfacing PWM in 8051
No comments:
Post a Comment