How to Interface GSM with 8051
The project explains interfacing of the AT89C51 micro controller with the GSM module and the Hyper Terminal. Hyper Terminal is a Windows application. The AT commands are sent by the Hyper Terminal to the GSM module. The Information Response and/or Result Codes are received at the micro controller and re transmitted to the Hyper Terminal by the controller.
A GSM module has an RS232 interface for serial communication with an external peripheral. In this case, the transmit pin (Tx) of the computer’s Serial port is connected with the receive pin (Rx) of the GSM module’s RS-232 interface. The transmit pin (Tx) of the RS-232 of GSM module is connected to receive pin (Rx) of microcontroller’s serial transmission pin. And the serial transmit pin of the micro-controller is connected to the receive pin of the computer’s Serial port. Therefore the commands and their results are transmitted and received in a triangular fashion as depicted below.
Code :
A GSM module has an RS232 interface for serial communication with an external peripheral. In this case, the transmit pin (Tx) of the computer’s Serial port is connected with the receive pin (Rx) of the GSM module’s RS-232 interface. The transmit pin (Tx) of the RS-232 of GSM module is connected to receive pin (Rx) of microcontroller’s serial transmission pin. And the serial transmit pin of the micro-controller is connected to the receive pin of the computer’s Serial port. Therefore the commands and their results are transmitted and received in a triangular fashion as depicted below.
Code :
// Program to interface GSM Module with 8051 micro controller (AT89C51) using PC //for more please visit http://vaneeswarann.blogspot.in/ #include<reg51.h> unsigned char str; void init_serial() // Initialize serial port { TMOD=0x20; // Mode=2 TH1=0xfd; // 9600 baud SCON=0x50; // Serial mode=1 ,8-Bit data,1 Stop bit ,1 Start bit , Receiving on TR1=1; // Start timer } void transmit_data(unsigned char str) // Function to transmit data through serial port { SBUF=str; // Store data in sbuf while(TI==0); // Wait till data transmit TI=0; } void receive_data() interrupt 4 // Function to receive data serially from RS232 into micro-controller { str=SBUF; // Read sbuf RI=0; transmit_data(str); // Transmit to HyperTerminal } void main() { init_serial(); // Initialize serial port IE=0x90; while(1); }