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 PIC18F4520 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.
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.
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
Schematic
Code
// ********************************************************* // Project: Interfacing GSM to PIC18F4520 microcontroller // Author: Hack Projects India // Module description: Operate GSM // *********************************************************#include<p18f4520.h> #pragma config OSC=HS, FCMEN=ON, WDT=OFF, IESO=OFF, XINST=OFF, LVP=OFF 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() { 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 USART_Init(void) // INITIALIZE SERIAL PORT { SPBRG =0x19; // 9600 bps at XTA=4MHZ TXSTA=0X24; // Transmission part enable RCSTA=0x90; // Receiving part enable } void USART_Transmit(unsigned char serialdata) { TXREG=ch; // Character send through transmission register while(!PIR1bits.TXIF); // Upto transmitting character } void Tx_String( char *str) { while(*str) { USART_Transmit(*str); str++; delay(200); } }
Downloads:
The code was compiled in Keil uvision4 and simulation was made in Proteus v7.7.
To download code and proteus simulation click here.
Further Reading suggestions:
You may also like,
- Interfacing keypad with PIC
- nterfacing DAC with PIC
- Interfacing with UART of PIC controller
- Interfacing SPI communication with PIC
- PIC Displaying Custom Characters on LCD
- PIC Graphical LCD
- RTC interfacing using I2C in PIC
- Interfacing ultrasonic sensor with PIC
- Interfacing GPS Modu with PIC
- Interfacing PWM in PIC
- Interfacing ADC with PIC
- Scrolling string on LCD using PIC
- Interfacing keypad with PIC
- nterfacing DAC with PIC
- Interfacing with UART of PIC controller
- Interfacing SPI communication with PIC
- PIC Displaying Custom Characters on LCD
- PIC Graphical LCD
- RTC interfacing using I2C in PIC
- Interfacing ultrasonic sensor with PIC
- Interfacing GPS Modu with PIC
- Interfacing PWM in PIC
- Interfacing ADC with PIC
- Scrolling string on LCD using PIC
No comments:
Post a Comment