Sending MSG through GSM module

this project present a way to transmit textual data by use of GSM module and a brief introduction about AT commands. As a GSM module works on AT commands for communication our controller is programmed to send all these commands according to our reliability. you can also check these commands through hyper-terminal on your pc before designing your code and we also recommend you to check these AT commands on your pc. if either of your module or sim is not working, it will return ‘ERROR’ message on hyper-terminal. we'll focus here on GSM interfacing with 8051 without making use of pc by sending simple MSG "HELLO" via GSM module while 16*2 LCD connected with controller simultaneously displays the current status of system

NOTE: strictly recommended to use crystal with frequency 11.0592MHZ  

PROTEUS DESIGN

CODE

#include<reg51.h>
#define lcdport P2
sbit rs=P1^0;
sbit rw=P1^1;  
sbit en=P1^2;
void transmit(char);
void delay(unsigned int);
void lcdcmd(char);
void lcdstring(char *);
void longdelay(unsigned int);
void lcdint();
void lcddata(char);
unsigned char Command_AT[]="AT\r";
unsigned char text_mode[]="AT+CMGF=1\r";
unsigned char send_msg[]="AT+CMGS =\"+91880232xxxx\"\r";
unsigned char msg[]="Hello";
void uart_int()
{
TMOD=0x20;
TH1=0xfd;
SCON=0x50;
TR1=1;
}
void transmitstring(char *s)
{
while(*s!='\0')
{
transmit(*s);
delay(500);
s++;
}
}
void transmit(char a)

SBUF=a;
while(TI==0);
TI=0;
}
void communication()
{
transmitstring(Command_AT);//AT commands to initialize gsm modem
longdelay(800);
transmitstring(text_mode);//select text mode for sms
longdelay(800);
transmitstring(send_msg);
longdelay(800);
transmitstring(msg);
longdelay(300);
transmit(0x1A);//cntl+z
longdelay(300);
lcdcmd(0x01);
lcdcmd(0x80);
lcdstring("MSG delivered");
longdelay(50000);
}
void main()
{
P1=0x00;
P2=0x00;
lcdint();
uart_int();
    delay(500);
while(1)
  {
   lcdstring("GSM BASED");
   lcdcmd(0xc8);
   delay(500);
   lcdstring("PROJECT");
   delay(50000);
   communication();
   delay(500);
   while(1)
   {
   ;
   }
  }
}
void delay(unsigned int x)
{
unsigned int i;
for(i=0;i<x;i++);
}
void longdelay(unsigned int y)
{
unsigned int j,k;
for(j=0;j<y;j++)
for(k=0;k<1275;k++);
}
void lcdint()
{
  lcdcmd(0x38);
  delay(500);
  lcdcmd(0x01);
  delay(500);
  lcdcmd(0x0c);
  delay(500);
  lcdcmd(0x80);
  delay(500);
  lcdcmd(0x0e);
  delay(500);
}
void lcdcmd(char value)
{
  lcdport = value;
  rw=0;
  rs=0;
  en=1;
  delay(500);
  en=0;
}
void lcdstring(char *p)
{
  while(*p!='\0')
   {
     lcddata(*p);
     delay(2000);
     p++;
   }
}
void lcddata(char value)
{
  lcdport=value;
  rs=1;
  rw=0;
  en=1; 
  delay(500);
  en=0;
}

 

you may also buy this(8051) kit at RS400/-(excluding shipping charge) mail us at [email protected]

VIDEO

Category: 

tags: 

Share

Who's new

  • ravirajpatil871...
  • shubhambajoria
  • yassir
  • demiholyman890954
  • scottgillum51169040

Get Notified

 

Share

We are Social

Syndicate

Subscribe to Syndicate