Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Interfacing GSM Module with 8051 microcontroller (AT89C51) without using PC- (Part 40/45)

By Himanshu Choudhary December 29, 2010

This project presents a way to interface GSM module with microcontroller AT89C51 without making use of computer to send AT commands to the module. This is an improvement over the previous projects (see MC074 & MC075). Instead of using HyperTerminal or any other PC interface, the controller itself sends a fixed AT command to the GSM/GPRS module. The information response and result codes are received and displayed on a 16x2 LCD.
 

 


 

Instead of sending commands from the HyperTerminal, AT commands are sent to the GSM/GPRS module by the microcontroller itself. In this case, the receive (Rx) and transmit (Tx) pin of the GSM module’s RS232 port are connected to the transmit (Tx) and receive (Rx) pin of AT89C51’s serial port, respectively. This eliminated the role of computer and just the controller’s circuit provides a complete user interface for the module.
 
 Block Diagram Of GSM Module with 8051 Microcontroller
Fig. 2: Block Diagram Of GSM Module with 8051 Microcontroller
 
The controller is programmed to send a fixed command ‘AT’ to the module. The command AT is used to check the communication with module. It returns a result code OK if the module and the controller are connected properly. If either of the module or SIM are not working, it returns a result code ERROR.
The program complexities for display of information responses and result codes on LCD mentioned in MC075 remain same here as well.
 

Project Source Code

###

// Program to Interface GSM Module with 8051 microcontroller (AT89C51) without using PC

#include<reg51.h>
#define port P1
#define dataport P2				// Data port for LCD
sbit rs = port^2;
sbit rw = port^3;
sbit en = port^4;
int count,i;
unsigned char check,str[15];
bit check_space;

void init_serial()			// Initialize serial port
{
	TMOD=0x20;			// Mode2
	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 delay(unsigned int msec)		// Function for delay
{
	int i,j;
	for(i=0;i<msec;i++)
	    for(j=0; j<1275; j++);
}

void lcd_cmd(unsigned char item)		// Function to send command on LCD
{
	dataport = item;
	rs= 0;
	rw=0;
	en=1;
	delay(1);
	en=0;
	return;
} 

void lcd_data(unsigned char item)		// Function to display character on LCD
{
	dataport = item;
	rs= 1;
	rw=0;
	en=1;
	delay(1);
	en=0;
	return;
}
	 	
void lcd_data_string(unsigned char *str)	// Function to display string on LCD
{
	int i=0;
	while(str[i]!='')
	{
 	  lcd_data(str[i]);				  
 	  i++;
 	  delay(10);						  				
   	}
	return; 
}
void lcd()
{
	lcd_cmd(0x38);		  				// For using 8-bit 2 row LCD 
	delay(5);			  						
	lcd_cmd(0x0F);        					// For display on cursor blinking
	delay(5);			 						
	lcd_cmd(0x80);		  				// Set the cursor on first position of LCD 
	delay(5);			  						
}

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 transmits
	TI=0;			  
}

 void receive_data()  interrupt 4	// Function to recieve data serialy from RS232 into microcontroller
 {	 
	RI=0;
	str[++count]=SBUF; 			//Read SBUF
	 
 }
  
unsigned char byte_check() 		// Function to check carraige return and new line character
{
	switch(str[0])
	{
		case 0x0a:
		{				// Return 0x00 for new line
		return 0x00;
		break ;
		}
		case 0x0d:
		{				// Return 0x01 for carriage return
		return 0x01;
		break ;
		}
		default :return 0x02 ;		// Return 0x02 for characters except new line and carriage return
	}
}

void main()
{ 
	lcd();								// Initialize LCD
	init_serial();							// Initialize serial port
	count=(-1);
	delay(500);
	lcd_data_string("Ready");
	delay(10);			 					
	lcd_cmd(0x01);	
	IE=0x94; 
	transmit_data('A');	  				// Transmit 'A' to serial port
	delay(1);
	transmit_data('T');	 				// Transmit 'T' to serial port
	delay(1);
	transmit_data(0x0d);  					// Transmit carriage return to serial port
	delay(50);
	while(1)
	{
		if(count>=0)
		{
			check=byte_check();	 			// Check the character
			if(check!=0x00)
			{			
				if(check==0x01)
				{
					if(check_space==1)	 	// Check previous character
					{
						lcd_data(0x20);
						check_space=0;
					}
				}
				else	
				{
					lcd_data(str[0]);
					check_space=1;
				}
			}
			count--;				   
			for(i=0;i<count;i++)	  		// Shift the whole array to one left
			{
				str[i]=str[i+1];
			}
		}
	}
}

###

 


Circuit Diagrams

Circuit-Diagram-Interfacing-GSM-Module-8051-Microcontroller-AT89C51-Without-Using-PC

Project Components

  • AT89C51 Microcontroller
  • LCD
  • MAX232


Filed Under: 8051 Microcontroller

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Multiple DC/DC converters and a single input source
  • Voltage mode pushpull is a nonsense SMPS?
  • High Side current sensing
  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • MOSFET thermal noise in Weak vs Strong inversion

RSS Electro-Tech-Online.com Discussions

  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts
  • Wideband matching an electrically short bowtie antenna; 50 ohm, 434 MHz
  • Curved lines in PCB design
  • using a RTC in SF basic

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe