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.

GSM modem with PIC 16F877A

Status
Not open for further replies.
anyone can help about on how to send at command to the gsm module using 16f877a in assembly. . . .any reply is highly appreciated. . .tanx
 
  • Like
Reactions: akatsu

    akatsu

    Points: 2
    Helpful Answer Positive Rating
I have some gsm phones, but their not that old, i wonder if i can use them for this kind of project?

Alcatel C717, Alcatel E801 and Alcatel C630
 

Hi all,
I also doing same project send sms via PIC and Mobile phone(sony ericsson K700).I did some proteus simulations as in my attachement. In there you can see although there are AT commands are sending between PIC and MAX232 something uncommon between MAX232 and phone.
Can you clarify this

Thanks[/img]
 

Thank You Very much i am new with pic's, could you give a bit more info

coldy said:
Hmmm ok i will try,

But frankly speaking i believe there should be another reason,
even maybe tooooo simple :) hehe

thanks anyway,

Added after 4 hours 33 minutes:

Thanks to your kind suggestions all,

In fact, Ajay Bhargav from 8051projects.net forum, I really appreciate his latest comment .

The solution is; making some additional connections at GSM serial port, as below;
**broken link removed**


Before I only connected, RX,TX and GRND pins of the GSM serial port.

And below you can see the general connection latest I made:
**broken link removed**


And a program to send sms and or call a phone number is as follows:
Code:
'Definitions
DEFINE OSC 4			'for 4 Mhz
'DEFINE OSC 8			'for 8 Mhz

DEFINE HSER_TXSTA 20h	'I wonder shall I define as DEFINE HSER_TXSTA 24h???
DEFINE HSER_RCSTA 90h	'same for all

DEFINE HSER_BAUD 2400	'for 2400 Baud rate
'DEFINE HSER_BAUD 4800	'for 4800 Baud rate
'DEFINE HSER_BAUD 9600	'for 9600 Baud rate

DEFINE HSER_SPBRG 25		'for 4Mhz/2400 & 8Mhz/4800 with an error %0.16
'DEFINE HSER_SPBRG 12	'for 4Mhz/4800 & 8Mhz/9600 with an error %0.16

DEFINE HSER_CLROERR 1	'same for all

' Initialization & Declaration
i var byte
TRISB=%00000000
PORTB=%00000000
TRISD=%00001111
PORTD=%00000000

' CHECK
FIRSTCHECK:
    HIGH PORTB.7
    PAUSE 500
    HIGH PORTB.6
    PAUSE 500
    HIGH PORTB.5
    PAUSE 500
    HIGH PORTB.4
    PAUSE 500
    PORTB=%00000000

GSM_CHECK:
HSEROUT ["AT",13]                    'Send AT to modem followed by a CR
HSERIN 5000, GSM_CHECK, [WAIT("OK")] 'Check OK reply, wait 5sec max.
HIGH PORTB.7
PAUSE 1000

HSEROUT ["AT+GMM",13]                           'Ask model name
HSERIN 5000, GSM_CHECK, [WAIT("T610 series")]   'Check model name
HIGH PORTB.6
PAUSE 1000

HSEROUT ["AT+IPR=2400",13]      'Set transfer speed
HSERIN 5000, GSM_CHECK, [WAIT("OK")]'Check OK reply, wait 5sec max.
HIGH PORTB.5
PAUSE 1000

HSEROUT ["AT+CMGF=1",13]            'send AT to modem followed by a CR and line feed
HSERIN 5000, GSM_CHECK, [WAIT("OK")]'Check OK reply, wait 5sec max.
HIGH PORTB.4
PAUSE 1000

PORTB=%00000000

BEGIN:
IF PORTB.5=1 THEN ERROR_CALL
IF PORTB.6=1 THEN ERROR_SMS
HIGH PORTB.7
pause 1000
LOW PORTB.7
if PORTD.2 = 0 then SEND_SMS
IF PORTD.3 = 0 THEN CALL_PHONE
PAUSE 1000
GOTO BEGIN

SEND_SMS:
HIGH PORTB.6
HSEROUT ["at+cmgs=",34,"XXXXX",34,13]
PAUSE 1000
HSEROUT ["this is a test message",26]
HSERIN 10000, BEGIN, [WAIT("OK")]'Check OK reply, wait 5sec max.
LOW PORTB.6
GOTO BEGIN

CALL_PHONE:
HIGH PORTB.5
HSEROUT ["atd[XXXXX];",13]
HSERIN 5000, BEGIN, [WAIT("OK")]'Check OK reply, wait 5sec max.
PAUSE 2000
LOW PORTB.5
GOTO BEGIN

ERROR_CALL:
FOR i = 1 to 5
HIGH PORTB.4
PAUSE 500
LOW PORTB.4
PAUSE 500
next i
PORTB=%00000000
GOTO BEGIN
    
ERROR_SMS:
FOR i = 1 to 5
HIGH PORTB.4
PAUSE 500
LOW PORTB.4
PAUSE 500
next i
PORTB=%00000000
GOTO BEGIN

' END
End

Thanks again for your attention and time, I will continue with :
- Improving the program to a real case scenario,
- Think more about the real case scenario, because at first stage I would like to use this as an alarm system for my garden house. I will need some sensors for unexpected visitors or animals.

Do you have any idea, what kind of sensors I can use to detect unexpected visitors?

Regards,
 

tharaka said:
Hi all,
I also doing same project send sms via PIC and Mobile phone(sony ericsson K700).I did some proteus simulations as in my attachement. In there you can see although there are AT commands are sending between PIC and MAX232 something uncommon between MAX232 and phone.
Can you clarify this

Thanks[/img]

Hi, cant speak english good, but I have a dude, the Mobile phone sony ericsson K700 use Text mode or PDU mode for comunication with the PC or PIC, or is a modifiable parameter?

Thanks
 

hai,

first check which mode ur phone is in default.with this following AT coomand

AT+CMGF?
if its 0 -->PDU mode
1--->text mode
ya it can be modified via like
AT+CMGF=1

text mode is the best method.

regards,

karthikeyan
 

hello GSM man.

i have similar project too. but in my case i have to use PIC to send sms through GSM mobile/modem (havent decided yet)

my project is about alarm monitoring system.
my question is:
1- how can i connect 3 sensors with 5 level output each to a PIC ? is that even possible? is there such PIC microcontroller that have this capability?
for example a rain gauge with

level 1- no rain
level 3- moderate
level 5- heavy

2- i understand that PIC use 0v -5v . can i use this 0 - 5v to represent such sensor level?
3- is it possible to program pic using at commands to send sms that displays all three sensor status in one message?
example if one sensor change level the pic will trigger to send sms through gsm
but will display all three sensor level even though it was only one sensor changed level.
4- correct me if im wrong. but the way i understand it. once the PIC is triggered, it will call a pre set sms message stored in GSM modem sim to send? or is there such programming to do that make an sms message through at commands but not a pre -set sms in the sim?. im realy sorry to this stupid question but im really a noob when it comes to programming so my imagination is not that wide.

i really need some help GSM man. tnx
 

hello Max123 were u able to find a solution for your problem?
because im also having the same problem im able to send the at command but the pic is not able to read msg from the gsm module. please help me
 

Cold
please help me ,I want to learn interfacing between pic18F and GSM. I want to learn from start, Please guide me in terms of giving me link of any tutorial or any thiing

Thanks
 

casn anyone help me im in the deadlin but my problem is i can communicate my mobile phone to the phone connected to the pic sms.JPG

and here is my code

#define TRIGGER PORTD.F1 // set porta/f5 as output


unsigned int index=0,count=0,address=0,addrLength=247,intFlag=0;
unsigned short intTimer;
unsigned char msg[30], mess[20];

void textMode();
void phoneMem();
void readMsg();
void delMsg();
void check_message();
void SMSProcess();


void interrupt()
{
intTimer++;
PIR1.TMR1IF=0;
if(intTimer%10==0){
if(intTimer%20==0){
intFlag=1;
}
}
}
//SMS processing
void textMode()
{ // Set message format as textmode

Usart_Write('A');
Usart_Write('T');
Usart_Write(0x0D);
delay_ms(500);

Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('M');
Usart_Write('G');
Usart_Write('F');
Usart_Write('=');
Usart_Write('1');
Usart_Write(0x0D);
delay_ms(1000);
}
void ckpd() { // Received read message
Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('K');
Usart_Write('P');
Usart_Write('D');
Usart_Write('=');
Usart_Write('1');
Usart_Write(0x0D);
}


void phoneMem() { // Set preferred message storage as Phone Memory

Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('P');
Usart_Write('M');
Usart_Write('S');
Usart_Write('=');
Usart_Write('"');
Usart_Write('M');
Usart_Write('E');
Usart_Write('"');
Usart_Write(0x0D);
delay_ms(1000);

}




void readMsg() { // Received read message
Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('M');
Usart_Write('G');
Usart_Write('R');
Usart_Write('=');
Usart_Write('1');
Usart_Write(0x0D);
}


void delMsg() { // Delete message for preferred message memory
Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('M');
Usart_Write('G');
Usart_Write('D');
Usart_Write('=');
Usart_Write('1');
Usart_Write(0x0D);
delay_ms(500);
}


void check_message() { // check message status
if(strcmp(mess,"Unlock")==0){
TRIGGER=1; // trigger relay
delay_ms(2000);
TRIGGER=0;
}
}
void main() {
TRISA=0x3F;
ADCON1=0x06;
PORTA=0x00;
TRISB = 0X00;
PORTB=0x00;
TRISD=0x00; // Set PORT D as OUPTPUT
PORTD=0x00;

Usart_Init(9600);

intTimer = 0;

TRIGGER=0;

INTCON.GIE = 1;
INTCON.PEIE= 1;
T1CON=0x30;
T1CON.TMR1ON=1;
PIR1.TMR1IF=0;
PIE1.TMR1IE=0;

textMode();
phoneMem();

TMR1H=0x00;
TMR1L=0x00;

}

int extract_message(){ // extract the message from the cellphone
int x=0,y=0,flag=1;
char a;


readMsg();
while(x!=10000){

if(Usart_Data_Ready()){
y++;
a=Usart_Read();
if(a=='r'||a=='R'){
flag=0;
break;
}
if(y>=70)
{
if(a!='O' && a!='K' && isalpha(a))
{
msg[x++]=a;

}

}


x++;

}
PIE1.TMR1IE=1;
return flag;
}


}
 

can anyone help me in this matter the purposed of this project is to control 4 relays
 

Is that the project like this.

sir no weare not using gsm module we are using a sony erikson t230 mobile phone

---------- Post added at 06:53 ---------- Previous post was at 06:50 ----------

here is my new code but nothing happens in the simulation


unsigned int index=0,count=0,address=0,addrLength=247,inbox=0,intFlag=0;
unsigned char msg[30], mess[20];

void textMode();
void phoneMem();
void readMsg();
void delMsg();
void check_message();
void SMSProcess();
int extract_message();
void ckpd();

void main()
{
TRISA=0x3F;
ADCON1=0x06;
PORTA=0x00;
TRISB = 0X00;
PORTB=0x00;
TRISD=0x00; // Set PORT D as OUPTPUT
PORTD=0x00;

Usart_Init(9600);

INTCON.GIE = 1;
INTCON.PEIE= 1;
T1CON=0x30;
T1CON.TMR1ON=1;
PIR1.TMR1IF=0;
PIE1.TMR1IE=0;


textMode();
phoneMem();

ckpd();

while(1)
{
SMSProcess();
Delay_ms(2000);
}
}

void textMode() { // Set message format as textmode

Usart_Write('A');
Usart_Write('T');
Usart_Write(0x0D);
delay_ms(500);

Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('M');
Usart_Write('G');
Usart_Write('F');
Usart_Write('=');
Usart_Write('1');
Usart_Write(0x0D);
delay_ms(1000);
}
void ckpd() { // Received read message
Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('K');
Usart_Write('P');
Usart_Write('D');
Usart_Write('=');
Usart_Write('1');
Usart_Write(0x0D);
}


void phoneMem() { // Set preferred message storage as Phone Memory

Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('P');
Usart_Write('M');
Usart_Write('S');
Usart_Write('=');
Usart_Write('"');
Usart_Write('M');
Usart_Write('E');
Usart_Write('"');
Usart_Write(0x0D);
delay_ms(1000);

}




void readMsg() { // Received read message
Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('M');
Usart_Write('G');
Usart_Write('R');
Usart_Write('=');
Usart_Write('1');
Usart_Write(0x0D);
}


void delMsg() { // Delete message for preferred message memory
Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('M');
Usart_Write('G');
Usart_Write('D');
Usart_Write('=');
Usart_Write('1');
Usart_Write(0x0D);
delay_ms(500);
}


void check_message()
{ // check message status
if(strcmp(mess,"on")==0)
{
PORTD=1; // trigger relay
delay_ms(50);
}
if(strcmp(mess,"off")==0){
PORTD=0; // trigger relay

}
}


void SMSProcess(){ // SMS processing routine
int message_index=0;
PIE1.TMR1IE=0;

if(extract_message()==1){
for(message_index=0;message_index<inbox;message_index++){
if(isalpha(msg[message_index]))
mess[message_index]=msg[message_index];
}
mess[message_index]='\0';
check_message();
delay_ms(3000);
delMsg() ;
}
}

int extract_message(){ // extract the message from the cellphone
int x=0,y=0,flag=1;
char a;
inbox=0;

readMsg();
while(x!=10000){

if(Usart_Data_Ready()){
y++;
a=Usart_Read();
if(a=='r'||a=='R'){
flag=0;
break;
}
if(y>=70){
if(a!='O' && a!='K' && isalpha(a)){
msg[inbox++]=a;
}

}

}
x++;

}
return flag;
}


hope someone can help me in this matter
 

How you connect microcontroller with that mobile phone? UART/RS232 using AT Command also?

sir we use Sony Ericsson t230 and with the help of AT commands so that the pic and the mobile phone can communicate each other....
below is the sample code

unsigned int index=0,count=0,address=0,addrLength=247,inbox=0,intFlag=0;
unsigned char msg[30], mess[20];

void textMode();
void phoneMem();
void readMsg();
void delMsg();
void check_message();
void SMSProcess();
int extract_message();
void ckpd();

void main()
{
TRISA=0x3F;
ADCON1=0x06;
PORTA=0x00;
TRISB = 0X00;
PORTB=0x00;
TRISD=0x00; // Set PORT D as OUPTPUT
PORTD=0x00;

Usart_Init(9600);

INTCON.GIE = 1;
INTCON.PEIE= 1;
T1CON=0x30;
T1CON.TMR1ON=1;
PIR1.TMR1IF=0;
PIE1.TMR1IE=0;


textMode();
phoneMem();

ckpd();

while(1)
{
SMSProcess();
Delay_ms(2000);
}
}

void textMode() { // Set message format as textmode

Usart_Write('A');
Usart_Write('T');
Usart_Write(0x0D);
delay_ms(500);

Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('M');
Usart_Write('G');
Usart_Write('F');
Usart_Write('=');
Usart_Write('1');
Usart_Write(0x0D);
delay_ms(1000);
}
void ckpd() { // Received read message
Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('K');
Usart_Write('P');
Usart_Write('D');
Usart_Write('=');
Usart_Write('1');
Usart_Write(0x0D);
}


void phoneMem() { // Set preferred message storage as Phone Memory

Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('P');
Usart_Write('M');
Usart_Write('S');
Usart_Write('=');
Usart_Write('"');
Usart_Write('M');
Usart_Write('E');
Usart_Write('"');
Usart_Write(0x0D);
delay_ms(1000);

}




void readMsg() { // Received read message
Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('M');
Usart_Write('G');
Usart_Write('R');
Usart_Write('=');
Usart_Write('1');
Usart_Write(0x0D);
}


void delMsg() { // Delete message for preferred message memory
Usart_Write('A');
Usart_Write('T');
Usart_Write('+');
Usart_Write('C');
Usart_Write('M');
Usart_Write('G');
Usart_Write('D');
Usart_Write('=');
Usart_Write('1');
Usart_Write(0x0D);
delay_ms(500);
}


void check_message() { // check message status
if(strcmp(mess,"on")==0){
PORTD=1; // trigger relay
delay_ms(2000);
PORTD=0;
}
}


void SMSProcess(){ // SMS processing routine
int message_index=0;
PIE1.TMR1IE=0;

if(extract_message()==1){
for(message_index=0;message_index<inbox;message_index++){
if(isalpha(msg[message_index]))
mess[message_index]=msg[message_index];
}
mess[message_index]='\0';
check_message();
delMsg();
delay_ms(3000);
}
}

int extract_message(){ // extract the message from the cellphone
int x=0,y=0,flag=1;
char a;
inbox=0;

readMsg();
while(x!=10000){

if(Usart_Data_Ready()){
y++;
a=Usart_Read();
if(a=='r'||a=='R'){
flag=0;
break;
}
if(y>=70){
if(a!='O' && a!='K' && isalpha(a)){
msg[inbox++]=a;
}

}

}
x++;

}
return flag;
}
 

sir we use Sony Ericsson t230 and with the help of AT commands so that the pic and the mobile phone can communicate each other....
below is the sample code
I don't understand flow of your code.
I give flow what I have done.

At power up, I delete SMS on location 0. PIC send UART 'AT+CMGD=1,0'
Then PIC waiting for SMS coming. PIC keep testing to receive UART 'AT+CMTI'
When, the SMS receive, PIC reads the SMS. PIC send UART 'AT+CMGR=1'
I display on LCD what the UART receive. ex: +CMGR: “REC UNREAD”,”0146290800”,”98/10/01,18:22:11+00”,<CR><LF>ABCdefGHI
Then I filtering this array, to get the phone number and the message.
For easy, I take the data after the third " and sixth ".
 

Re: pic, gsm modem, circuit

C5 is wrong, check max232 datasheet.
 

Hmmm ok i will try,

But frankly speaking i believe there should be another reason,
even maybe tooooo simple :) hehe

thanks anyway,

Added after 4 hours 33 minutes:

Thanks to your kind suggestions all,

In fact, Ajay Bhargav from 8051projects.net forum, I really appreciate his latest comment .

The solution is; making some additional connections at GSM serial port, as below;
**broken link removed**


Before I only connected, RX,TX and GRND pins of the GSM serial port.

And below you can see the general connection latest I made:
**broken link removed**


And a program to send sms and or call a phone number is as follows:
Code:
'Definitions
DEFINE OSC 4			'for 4 Mhz
'DEFINE OSC 8			'for 8 Mhz

DEFINE HSER_TXSTA 20h	'I wonder shall I define as DEFINE HSER_TXSTA 24h???
DEFINE HSER_RCSTA 90h	'same for all

DEFINE HSER_BAUD 2400	'for 2400 Baud rate
'DEFINE HSER_BAUD 4800	'for 4800 Baud rate
'DEFINE HSER_BAUD 9600	'for 9600 Baud rate

DEFINE HSER_SPBRG 25		'for 4Mhz/2400 & 8Mhz/4800 with an error %0.16
'DEFINE HSER_SPBRG 12	'for 4Mhz/4800 & 8Mhz/9600 with an error %0.16

DEFINE HSER_CLROERR 1	'same for all

' Initialization & Declaration
i var byte
TRISB=%00000000
PORTB=%00000000
TRISD=%00001111
PORTD=%00000000

' CHECK
FIRSTCHECK:
    HIGH PORTB.7
    PAUSE 500
    HIGH PORTB.6
    PAUSE 500
    HIGH PORTB.5
    PAUSE 500
    HIGH PORTB.4
    PAUSE 500
    PORTB=%00000000

GSM_CHECK:
HSEROUT ["AT",13]                    'Send AT to modem followed by a CR
HSERIN 5000, GSM_CHECK, [WAIT("OK")] 'Check OK reply, wait 5sec max.
HIGH PORTB.7
PAUSE 1000

HSEROUT ["AT+GMM",13]                           'Ask model name
HSERIN 5000, GSM_CHECK, [WAIT("T610 series")]   'Check model name
HIGH PORTB.6
PAUSE 1000

HSEROUT ["AT+IPR=2400",13]      'Set transfer speed
HSERIN 5000, GSM_CHECK, [WAIT("OK")]'Check OK reply, wait 5sec max.
HIGH PORTB.5
PAUSE 1000

HSEROUT ["AT+CMGF=1",13]            'send AT to modem followed by a CR and line feed
HSERIN 5000, GSM_CHECK, [WAIT("OK")]'Check OK reply, wait 5sec max.
HIGH PORTB.4
PAUSE 1000

PORTB=%00000000

BEGIN:
IF PORTB.5=1 THEN ERROR_CALL
IF PORTB.6=1 THEN ERROR_SMS
HIGH PORTB.7
pause 1000
LOW PORTB.7
if PORTD.2 = 0 then SEND_SMS
IF PORTD.3 = 0 THEN CALL_PHONE
PAUSE 1000
GOTO BEGIN

SEND_SMS:
HIGH PORTB.6
HSEROUT ["at+cmgs=",34,"XXXXX",34,13]
PAUSE 1000
HSEROUT ["this is a test message",26]
HSERIN 10000, BEGIN, [WAIT("OK")]'Check OK reply, wait 5sec max.
LOW PORTB.6
GOTO BEGIN

CALL_PHONE:
HIGH PORTB.5
HSEROUT ["atd[XXXXX];",13]
HSERIN 5000, BEGIN, [WAIT("OK")]'Check OK reply, wait 5sec max.
PAUSE 2000
LOW PORTB.5
GOTO BEGIN

ERROR_CALL:
FOR i = 1 to 5
HIGH PORTB.4
PAUSE 500
LOW PORTB.4
PAUSE 500
next i
PORTB=%00000000
GOTO BEGIN
    
ERROR_SMS:
FOR i = 1 to 5
HIGH PORTB.4
PAUSE 500
LOW PORTB.4
PAUSE 500
next i
PORTB=%00000000
GOTO BEGIN

' END
End

Thanks again for your attention and time, I will continue with :
- Improving the program to a real case scenario,
- Think more about the real case scenario, because at first stage I would like to use this as an alarm system for my garden house. I will need some sensors for unexpected visitors or animals.

Do you have any idea, what kind of sensors I can use to detect unexpected visitors?

Regards,





hello buddy,
u hav connected pin 7 of max232 to pin 2 of rs232 and pin 8 of max232 to pin 3 of rs232 in first post but
in next post u hav interchangd d conetction, wud u plz tel me whch one is corect?

thanx
 

PIC 16F877A

Hi,
I have a problem where i don't how to write a program for my rotation counter.
My system is a rotation counter, It count decrementally. does anyone here can help me on the programming part?

Thank you.
 

PIC 16F877A

Hi,
I have a problem where i don't how to write a program for my rotation counter.
My system is a rotation counter, It count decrementally. does anyone here can help me on the programming part?

Thank you.

You're looking for someone make your homework.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top