Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Problem in sending SMS through GSM module using 8051

Status
Not open for further replies.
ok now i decided that i will just check each command response
i read somewhere that gsm modem send OK for each successful retrieving of AT command
so i gust introduced serial interrupt for that and i am checking the response of "AT"

here is my code

#include"lcd.h"
unsigned char *command = "AT";

unsigned char CTRLZ = 0x1A, count;
unsigned char ar[5];
void serial_init(void);
void serial(unsigned char);
void puts(unsigned char *p );
void delay1(unsigned int);

void serial0() interrupt 4 {
if (TI==1) {
TI=0; //clear interrupt
}
else {
count=count+1;
ar[count]=SBUF;

RI=0; //clear interrupt
}
}

void main()
{
count=(-1);
init();
serial_init();
puts(command);
delay1(1000);

serial(CTRLZ);

print(&ar[0]);
while(1);

}
void serial_init(void)
{

TMOD=0x20; //timer 1, mode 2(8-bit autoreload) to set baud rate
TH1=0xFD; //-3 to TH1 for 9600 baud rate
SCON=0x50; // 8 bit txion, 1 start 1 stop bit, REN enable for both txfr and rxve
IE=0x90;
TR1=1; // start timer
}

void puts(char *p)
{
char *temp = p; /*temp pointer so that the actual pointer is not displaced */
while(*temp != 0x00)
{
serial(*temp);
temp++;
}
}

void serial(unsigned char x)
{

SBUF=x;
while(TI==0);
TI=0;

}

void delay1(unsigned int x)
{ int i,j;
for(i=0;i<x;i++)

for(j=0;j<1275;j++);

}

lcd.h header file contains this code:
#include<reg51.h>
sbit rs=P3^3;
sbit rw=P3^4;
sbit en=P3^5;
void dat(unsigned char);
void cmd(unsigned char);
void delay(unsigned int);
void print(unsigned char *);
void init();
void num(unsigned int);


void init()
{

cmd(0x38);
delay(100);
cmd(0x0E);
delay(100);
cmd(0x06);
delay(100);
cmd(0x01);
delay(100);
cmd(0x80);




}

void cmd(unsigned char x)
{
P2=x;
rs=0;
rw=0;
en=1;
delay(1);
en=0;
}
void dat(unsigned char y)
{
P2=y;
rs=1;
rw=0;
en=1;
delay(1);
en=0;
}
void delay(unsigned int z)
{
int j,i;
for(i=0;i<z;i++)
{
for(j=0;j<1275;j++);

}
}
void print(unsigned char *p)
{

while(*p!='\0')
{
dat(*p);
p++;
}

}




why iam not getting the "OK "on LCD?
 
If you do not get an OK from "AT" then nothing's going to work... The last time I dabbled in GSM, I hooked it up to a PC and got the commands working with 3 wire 9600,8,n to start with.... I cannot find the proper AT command set... I have only the extended AT set....

https://www.google.com/url?sa=t&rct...=q_qqV-XbrV97-T019UWLFQ&bvm=bv.92291466,d.d2s

Its quite intense but some good info in there... Is it possible to hook it up to your PC and get it working with hyper terminal or similar...
 
If you do not get an OK from "AT" then nothing's going to work... The last time I dabbled in GSM, I hooked it up to a PC and got the commands working with 3 wire 9600,8,n to start with.... I cannot find the proper AT command set... I have only the extended AT set....

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CDAQFjAC&url=https://download-c.huawei.com/download/downloadCenter?downloadId=14254&ei=MYVEVfaFFcraaMGcgfAF&usg=AFQjCNEMzu0fRDIXMPk4PMEyeo3h_meEkQ&sig2=q_qqV-XbrV97-T019UWLFQ&bvm=bv.92291466,d.d2s

Its quite intense but some good info in there... Is it possible to hook it up to your PC and get it working with hyper terminal or similar...



thank you sir,
i am using GSM module sim900A of Sim comm. company
isn't there any difference of working ?
will this article help me for this module?
 
GSM900/a is the model.... The actual modem is a Huawei EM820... So that's the datasheet to access AT command set...

As I said.... Get it up and running on a PC first...Open a terminal program and type "AT" and see if it replies.... If it does then you know its software on your part!!!
 
yes it didn't worked...

and i meant that i am not getting your code... i am not familiar with that #ifdef code lne
It just stops that part of the code being run because I wanted to mimic the Arduino code example exactly. Not really important.

GSM900/a is the model.... The actual modem is a Huawei EM820... So that's the datasheet to access AT command set...

As I said.... Get it up and running on a PC first...Open a terminal program and type "AT" and see if it replies.... If it does then you know its software on your part!!!
But calling works, and he's done it on Arduino as well? Apparently anyway.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top