Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SMS through GSM Modem SIM300 and at89c52

Status
Not open for further replies.

prabin20

Junior Member level 1
Junior Member level 1
Joined
Mar 16, 2011
Messages
16
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
INDIA
Visit site
Activity points
1,427
hi guys i m doing a project in which i have to send sms.but i couldnot able to send sms . i also wanted to display the modem responses on lcd. please upload program any who has already done this kind of project.....:-?

Code:
#include<at89x52.h>

#define lcd_data_pin P2
sbit BUSY=P2^7;
sbit rs=P1^0;
sbit rw=P1^1;
sbit en=P1^2;
sbit l=P1^3;  

void USART_Send(unsigned char *data2send);
void Delay(unsigned int msec);

void LCD_Init();
void LCD_Cmd(unsigned char comm,unsigned char Mode);
void LCD_Data(unsigned char disp);
void LCD_String(unsigned char *disp);

void Send_SMS(unsigned char *msg);
void Send_SMS2(unsigned char *msg);
void Get_IMEI();
void Make_Call(unsigned char *number);

unsigned char data2rcv[40];
unsigned int idx = 0;
unsigned char a = 0, i = 0, z = 0, j = 0;
unsigned char *num = "+919xxxxxxxxx";
unsigned char *dummy, *data2send = "Hello!";
unsigned char chr;

void main()
{
	P0 = 0x00; //not used
	P1 = 0x00; //Used for Appliances
	P2 = 0x00; //not used
	P3 = 0x03; //used for serial
	
	TMOD = 0x20;	                      
	SCON = 0x50;			       
	TH1 = 0xFD;	
	TR1 = 1;		

  EA = 1;
	ES = 1;
	
	l=0;
	LCD_Init();			   
	Delay(20);

	LCD_Cmd(0x01,0);
	LCD_Cmd(0x84,0);
	LCD_String("WELCOME");
	Delay(50);
	LCD_Cmd(0xC4,0);
	LCD_String(" USER ");
	Delay(90);

	dummy = &data2rcv;
	
	if(l==1) {
				
				//USART_Send("8051");
				Delay(100);
				Send_SMS("Hello! Prabin");
				
	}
}


void serial_ISR (void) interrupt 4
{   
	if(RI==1)
	{
		data2rcv[idx] = SBUF;
		RI = 0;
		LCD_Data(data2rcv[idx]);
	}	
}

void Delay(unsigned int msec)   
{
	int i,j;
	for(i=0;i<msec;i++)
		for(j=0;j<1275;j++);
}

//LCD Functions

void LCD_Cmd(unsigned char comm,unsigned char Mode) 
{
	lcd_data_pin=comm;
	en=1;
	rs=Mode;
	rw=0;
	Delay(1);
	en=0;
}

void LCD_Data(unsigned char disp)   
{
	lcd_data_pin=disp;
	en=1;
	rs=1;
	rw=0;
	Delay(1);
	en=0;
}

void LCD_String(unsigned char *disp)    
{
	unsigned int cnt = 0;
	
	while(*disp)
	{
			LCD_Data(*disp++);
							
	}

}

void LCD_Init()     
{
	LCD_Cmd(0x38,0);   
	Delay(5);
	LCD_Cmd(0x06,0);       
	Delay(5);
	LCD_Cmd(0x0C,0);       
	Delay(5);
	LCD_Cmd(0x02,0);
	Delay(5);
}

//GSM Functions
//Send SMS Function

void Send_SMS(unsigned char *msg)
{
		
	USART_Send("AT\r");
	LCD_Cmd(0x01,0);
	LCD_Cmd(0x80,0);
	LCD_String("AT");
	LCD_Cmd(0xC0,0);
	
	Delay(500);
	LCD_String(dummy);
	USART_Send("AT+CMGF=1\r");
	LCD_Cmd(0x01,0);
	LCD_Cmd(0x80,0);
	LCD_String("AT+CMGF=1");
	LCD_Cmd(0xC0,0);
	
	Delay(500);
	LCD_String(dummy);
	USART_Send("AT+CMGS=\r");
	LCD_Cmd(0x01,0);
	LCD_Cmd(0x80,0);
	LCD_String("AT+CMGS=");
	LCD_Cmd(0xC0,0);
	
	USART_Send(0x22);
	USART_Send("+919531881579");
	LCD_Cmd(0x01,0);
	LCD_Cmd(0x80,0);
	LCD_String("+919531881579");
	LCD_Cmd(0xC0,0);
	USART_Send(0x22);
	Delay(500);
	USART_Send(msg);
	Delay(500);
	USART_Send(0x1A);
	USART_Send("SMS Sent...\r");
	LCD_Cmd(0x01,0);
	LCD_Cmd(0x80,0);
	LCD_String("SMS Sent...");
	LCD_Cmd(0xC0,0);
}

void Send_SMS2(unsigned char *msg)
{
      
  USART_Send("AT+CMGF=1\r");
  Delay(1000);
  USART_Send("AT+CMGS=\"");
  USART_Send(num);
  USART_Send("\"\r");
  Delay(1000);
  USART_Send(msg);
  USART_Send(26);
      
}



//Get IMEI

void Get_IMEI()
{
  USART_Send("AT+GSN\r");      
}

//Call Function

void Make_Call(unsigned char *number)
{
	USART_Send("ATDT ");
	USART_Send(number);
  USART_Send(";\r");   
      

}

//USART Functions
void USART_Send(unsigned char *data2send)
{
	
	while(*data2send)
	{
			SBUF = *data2send++;
			while(TI == 0);
			TI = 0;	
	}	
}
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top