GSM modem/Microcontroller

Status
Not open for further replies.

mohammad mustafa

Newbie level 4
Joined
Feb 12, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,342
Hi all i have a problem i hope you give me a Solution:

i have a project a bout security system via GSM modem i am using PIC16F877A for my job,M1306B GSM modem and Micro C programming language i send and receive SMS from GSM modemthese SMS is saved in the PIC and also the mobile numbers to which the SMS will be sent,my problem is that in every time i want to change the SMS content or insert/change a mobile number i have to change it first in the Micro C program,loading the program on the PIC again, i think it is not a practical solution, so please me in finding a method to insert any mobile number i want and change SMS content whenever i want without opening the micro C program and loading it every time on my PIC...
thanks
 

yar its very eaasy use a string name as number[] then save ur new number in it dynamically and when u use at_cmgs then use then get number frm this. same like for content of message.
 

thank you dear zia, but in below is a code foe sending SMS using Micro C source and PIC16F877A microcontroller

char i=0;
chat txt1[]="AT\r\n";
char txt2[]="AT+CMGF=1\r\n";
char txt3[]="AT+CNMI=2,0,0,1\r\n";
char txt4[]="AT+CMGS=";
char txt5[]="01146425848";
char txt6[]="Thank you";
void string1(char txt1[]){for(i=0;i<5;i++){Usart_Write(txt1);}}
void string2(char txt2[]){for(i=0;i<5;i++){Usart_Write(txt2);}}
void string3(char txt3[]){for(i=0;i<5;i++){Usart_Write(txt3);}}
void string4(char txt4[]){for(i=0;i<5;i++){Usart_Write(txt4);}}
void string5(char txt5[]){for(i=0;i<5;i++){Usart_Write(txt5);}}
void string6(char txt6[]){for(i=0;i<5;i++){Usart_Write(txt6);}}
void main(){
ADCON1=7;
TRISB=0;
Delay_ms(1500);
string1(txt1);
Delay_ms(500);
string1(txt1);
Delay_ms(500);
strin2(txt2);
Delay_ms(500);
string3(txt3);
Delay_ms(500);
strin4(txt4);
Usart_Write(0x34); // to write "
string5(txt5); // mobile number
Usart_Write(0x34);
Usart_Write(0x0d); // to insert ENTER
Delay_ms(500);
string6(txt6);
Usart_Write(0x1A); to insert CTRL+Z to send the SMS
Delay_ms(500);} // end of the code
here is SMS sending code my problem is that in every time i need to chane the mobile number i have to open the code and change the number
or the message but i want to do that directly through The Hyperterminal directly so please indicate what you said on that code.. thanks
 

if you want to save phone numbers dynamically you have to write additional code for receiving and parsing the incoming SMS which contains phone number you want to add/update. i.e. you can send phone numbers you want to add/update through SMS. If you want to change the numbers only from Hyperterminal, you can do that by using the command AT+CPBR (Phone book write) AT Command. You can then read that phone number and use it for sending SMS.
 

ok, is that mean after i burn the code on the microcontroller i can connect the microcontroller circuit to the computer directly
and using the command AT+CPBR i can change the mobile number and insert any new number without opening the code and burning it on the microcontroller
every time??

- - - Updated - - -

ok, is that mean after i burn the code on the microcontroller i can connect the microcontroller circuit to the computer directly
and using the command AT+CPBR i can change the mobile number and insert any new number without opening the code and burning it on the microcontroller
every time??is that also possible for changing the SMS content??
 

although it will be little difficult, still you can do that. I didn't try this yet. Because, I am sending SMS which contains the phone number to modem. Then parse the SMS and write the phone number in to PIC MCU.

Ok. Using HyperTerminal try using the tricky method.

For example:
1. use the USART.c & USART.h file comes with Hi-Tech C.
2. You can use the same sample code given along with Hi-tech C.
3. Instead of echo the received characters to Hyperterminal store in a string and check for <CR> that is ENTER char. If you received
<CR>, then terminate the string and save.

Try this.
 

View attachment serial1.bmp
my dear,in the above image it is how i deal with the Microcontroller with USART
it is a MicroC code the when i send "OK" i receive "Yes!" as follow:
char i=0;
char x[2];
char txt1[]="Yes!";
void string1(char txt1[]){for(i=0;i<4;i++){Usart_Write(txt1);}}
void main(){
Usart_Init(9600);
ADCON1=7;
TRISB=0;
PORTB=0;
loop0:
while(1){
if(Usart_Data_Ready()){
x=Usart_Read();
i++;
if(i==2){if(x[0]=='o'&&x[1]=='k'){Delay_ms(500);
string1(txt1);PORTB=2;
i=0;goto loop0;}}}}
goto loop0;}
this is my code as soon as i write OK to microC i receive Yes! without any problems
But when i open Hyperterminal on my PC and write OK i don't receive any thing
i can't deal with it,is there any protocols or Commands i have to add in my code to be able
to Connect between the Hyperterminal and my MicroC program??
i hope you help me...
 

Yes. MAX232 Or equivalent Converter IC should be used. Also, check on hyperterminal whatever the character you received from KeyBoard. From GSM Modem always <CR><LF> appended with strings. Also, set IPR matches with PIC configured in PIC, Select Flow Control as "None", 8 bit etc in Hyperterminal.
 

Hallo

you can also use https://www.ftdichip.com/Products/Cables/USBTTLSerial.htm
what you need to do, plug in the USB. it convert the data into TTL 5V for your microcontroller.
Basically, the microcontroller can receive the data from those TTL signal (as an input data for your phone number)..

**broken link removed**

You can also check the TTL data from PC (by Oscilloscope)
so you can make sure that you send the correct data.

If you have sent a correct serial signal, then you can start to deal with your microcontroller serial receiver program

Regards
 

Hi my dear, i think i found a good solution for what i want, thank you for every thing.. this time i want you i a simple and urgent help
as i said i use a GSM modules in my work but i think it is possible to a use a mobile phone instead of the module but i don't know how?
all what i know that it must be GSM module inside any Mobile phone so there must be Tx, Rx pins like that in the module
so i want to know how to use a simple mobile phone like (Nokia 1110) or an other type you know in that process as i find difficulty in buying the module from outside egypt
i think it will be so good if i used a mobile so i hope you help me in that...thanks i am waiting
 

Mustafa using mobile it is more coplex then using modem. as i recommend you to use interrupt recieve if u hyave pblm then let us know.but use right approach
 

all what i know that it must be GSM module inside any Mobile phone so there must be Tx, Rx pins like that in the module

Yes. You can. Try find out the name of the GSM/GPRS Module inside the phone and search the datasheet for the specific Module and find out the RX, TX pin. You can directly connect the TX, RX pin to PIC MCU, no need of converter ic (MAX232, etc). But, if you want to test Mobile phone through hyperterminal you should use MAX232 again.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…