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.

interfacing gsm modem and microcontroller AT89C51

Status
Not open for further replies.

Smruthi. R. K

Newbie level 5
Joined
Jan 5, 2009
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,367
pls reply...

is my question is clear to everyone?...pls reply fast..
i need your help..
thank you...will b waiting for the reply..
 

Re:thank you for the reply

hi..
we are doing project on interfacing gsm modem and microcontroller AT89C51.

*we are using sony ericcson w302 mobile as gsm modem..we have confirmed that it has got inbuilt modem..and we even checked some of at commands in hyperterminal..it even worked too..

*but when we wrote the assembly code to carry out the communication between the two..it's not working out..

*so can you please tell...what are the initial steps to be followed to carry out the communication???

it will be a great help..

this was the question...thank you for the reply...

Added after 11 minutes:

hi..
i am also doing project which requires interface between mobile(modem) and microcontroller..

i have checked the presence of modem in my mobile..through hyperterminal in pc..it gave response to some of the at commands i have sent...

but when i wrote the program am not getting response from the mobile...for the at commands sent from microcontroller serially...

the lookuptable i have used for sending at commands are..

toselmem:db "at+cpms=",22h,"sm",22h,0dh;

i am using assembly language..the command above is used to select memory...and 22h is eqvt of double quotes--ascii..0dh is for CR..sm for sim memory..

toreadmem:db "at+cmgr=1",0dh

my project is displaying the msg from the inbox of mobile on lcd display...

i think my question is still clear in this post..

thank you..
 

Re: pls reply...

Interesting project Smruthi. R. K..
Although I have worked on 89C51, I have not tried interfacing GSM modem yet..
Some one in this forum who has worked with GSM modem will surely help you..

Try to post the developments of your project in this thread, that may help other members who are planning to take up this type of project in future.. :)
 
pls help..

thank you srikanthsamaga..


can anybody help me regarding the same..which i have posted already..
thank you..
i wll be waiting for the reply..
 

Re: pls reply...

Hai Smruthi.....Hope the time for submission of the project is nearby. If you have some time to spare on this project, do contact www.united77.com in Mangalore. They do any sort of custom made projects. We have completed SMS controlled 8 appliances with LED based Notice board project with them. But we had submitted the idea about 2 months back. Now the working project is with us...Good luck
 
thank u for the reply Neha..

but we have already purchased all the components required for our project..
so i am thinking of utilizing all those things...and finishing off project successfully...

so can anybody please help me, will be waiting for very fast reply..

thank you..
 

Re: pls reply...

it will be very much helpful..if anyone can reply soon..
thank you..
 

RE:THANK YOU blueroomelectronics

HERE IS D PROGRAM


Program to read message from modem/mobile

ORG 0000H

LJMP 1000

ORG 1000

MOV TMOD,#20H

MOV SCON,#50H

MOV TH1,#0FDH

MOV R2,#14;COUNTER FOR SENDING 14 CHARACTERS
;OF AT COMMAND TO SELECT MEMORY

MOV IE,#90H

MOV DPTR,#TOSELMEM

REPTRANS: SETB TR1;TO SELECT MEMORY

CLR A

MOVC A,@A+DPTR

MOV SBUF,A

TRANSMIT: JNB TI,TRANSMIT

CLR TI

CLR TR1

INC DPTR

DJNZ R2,REPTRANS

STAYHERE: JB RI,LOOP;NEGLECTING 'OK' RESPONSE FROM
;THE MODEM HERE

SJMP OUT

LOOP: CLR RI

SJMP STAYHERE

OUT: MOV R3,#10;COUNTER FOR SENDING 10 CHARACTERS
;OF AT COMMAND TO READ MESSAGE FROM
;THE INBOX


MOV DPTR,#TOREADMEM

REPREAD: SETB TR1

CLR A

MOVC A,@A+DPTR

MOV SBUF,A

TRANSMIT1:JNB TI,TRANSMIT1

CLR TI

CLR TR1

INC DPTR

DJNZ R3,REPREAD

MOV R5,#10H

HERE: JNB RI,HERE

MOV A,SBUF

MOV DPTR,#3000;STORING THE RESPONSE FROM

;MOBILE AT 3000D MEM LOCATION

MOVX @DPTR,A

INC DPTR

CLR RI

CLR TR1

DJNZ R5,HERE

TOSELMEM: DB "AT+CPMS=",22H,"SM",22H,0DH

TOREADMEM:DB "AT+CMGR=1",0DH

please go through the code as soon as possible...will be waiting for the reply...thank you..
 

RE: pls help...

Is my program is clear? are some clarifications are required?

thank you...will be expecting your reply..
 

pls reply...

maybe it's a hardware issue, have you connected the microcontroller with the same cable you used to connecto to the PC? the PC COM port have a RS232 bit levels (0 +12v ; 1 -12v) but the microcontroller have TTL/cmos Levels (0 0v, 1 5v)... if you are connecting directtly, it will not work never! if you are using an extra max232, or conecting a different way as the PC... maybe the serial comunication is not working propertly, have you tried to communicate the micro and the Pc to check the communication???

mmm... I dont like how you set and clear TR1 at every byte, also, this way, the first bit will not work because you don't initalize TL1 to FDh, as th1...

you should comunnicate the micro with a PC in hyperterminal... maybe you would see the first A from "AT..." not going propertly...
 
Re: pls reply...

i am sorry blueroomelectronics..as i am a new member i was not knowing that i have to enclose the code in code section itself...

i will implement this from next posts..

thank you for the reply...

Added after 19 minutes:

thank you v.much for the reply Kurenai_ryu :D:D

ya..we have used line driver MAX232...

and ok as per your suggestion i will change the code a bit..and will initialise TL1 first with 0FDH...

and i dont know how to establish communication between pc and micro?? do we need to connect TXD, RXD, and GND pins of micro to the back of pc having
serial port..

actually we are using ride software to generate hex file..and in the debug mode...we have even done step by step execution...their in the UART buffer
we got the at command too..as according to our program..

but dont know why mob/modem is not responding to the at command...:(
 

Re: pls reply...

if you can reply fast..it will be a great help for me..
thank you...will be waiting for reply..
 

Re: pls reply...

Smruthi. R. K said:
if you can reply fast..it will be a great help for me..
thank you...will be waiting for reply..
Hai Smruthi R.K. As i saw all yours previous posts in this topic, every where you are in a hurry and were expecting a fast or sooner reply. As i pre assume you as a student and your project is concerned, there may be harware flaws at your end which cannot be corrected by any member on this forum. What we can do is, we can give you sugessions and guessing the faults at our liesure, which naturally will take little time.. Why dont you take help of any local professional project guides in your place so that the problems are solved faster than you expect here? Hope the submission date is nearby. So now you have to hurry up. Good luck...

Oh...yes...neha007 has given you the same sugession...I saw it just now.
 

Re: pls reply...

thank you for the reply pranam77..

ya i am in a hurry as project submission dates are nearby. But we have decided to do the project by our own..not taking any consultancies help..so i am taking this forum's help..and i will be very thankful if any body can help me..

thank you..
 

Hi!!
I have gone thr all forum details, can any one help me, how i can send the message and receive msg with 89c51 microcontroller interfacing with GSM modem,
in embedded C, some hints.

I hv known all the hyperterminal commands to send and receive the sms.
what is hardware connections.............pls help...


advanced thanx.
 

Hi,

I think you should start new topic to ask your question. May be you will get fast replies to your question.

Come to the question, If it's a serial modem you need to connect the modem to UART peripheral of the 8051. That means a line driver ic some what like Max 232 and a DB9 connector to its output which will connect to the modem.

First you connect modem with serial port of pc and check commands through hyperterminal then connect modem with microcontroller uart and develop commands with sending all commands using UART. Hope this helps.

NIKS
 

can anyone help me to combine these two programmes I want to read Gps data(latitude&longitude) and send with Gsm :
gps :
$regfile = "m16def.dat"
$crystal = 11059200
$baud = 9600
'-------------------------------------------------------------------------------
Config Lcd = 20 * 4
Cls
Cursor Off
'-------------------------------------------------------------------------------
Config Porta.1 = Output : Reset Porta.1
Config Portb.0 = Output : Led1 Alias Portb.0
'-------------------------------------------------------------------------------
Deflcdchar 0 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32
'-------------------------------------------------------------------------------
On Urxc Rec_isr
Enable Urxc
Enable Interrupts
'-------------------------------------------------------------------------------
'GPS variables
Dim Urx_buff As String * 550
Dim Cnt As Word
Dim M As String * 5
Dim Gpgga As String * 80
Dim Gpvtg As String * 80
Dim Gpgga_flag As Bit
Dim Gpvtg_flag As Bit
Dim V_counter As Byte
Dim I As Byte
Dim L As Byte
Dim F_utc_time As Byte
Dim E_utc_time As Byte
Dim F_longitude As Byte
Dim E_longitude As Byte
Dim F_latitude As Byte
Dim E_latitude As Byte
Dim F_altitude As Byte
Dim E_altitude As Byte
Dim F_speed As Byte
Dim E_speed As Byte
Dim F_sat_num As Byte
Dim E_sat_num As Byte
Dim Utc_time As String * 10
Dim Utc_time_k As String * 10
Dim Longitude As String * 12
Dim Latitude As String * 12
Dim Altitude As String * 8
Dim Speed As String * 8
Dim Sat_num As String * 4
Dim Sat_inuse As Byte
Dim S_k1 As Single
Dim S_k2 As Single
Dim R_k1 As String * 15
Dim N As Byte
'-------------------------------------------------------------------------------
Locate 1 , 1 : Lcd "GPS"
Locate 2 , 1 : Lcd "connecting..."
Locate 3 , 1 : Lcd "Please wait..."

Do
'-------------------------------------------------------------------------------
If Cnt > 520 Then
Set Led1
Disable Urxc
Gosub Get_nmeapaket
Gosub Extract
Reset Led1
Urx_buff = ""
Cnt = 0
Enable Urxc
End If
'--------------------------------------------------
Loop
End
'-------------------------------------------------------------------------------
Get_nmeapaket:
For Cnt = 1 To 500
M = Mid(urx_buff , Cnt , 5)
If M = "GPGGA" Then
Gpgga = ""
V_counter = 0
Do
M = Mid(urx_buff , Cnt , 1)
Incr V_counter
Incr Cnt
Gpgga = Gpgga + M
Loop Until V_counter > 78 Or M = "*"
Exit For
End If
Next
For Cnt = 1 To 500
M = Mid(urx_buff , Cnt , 5)
If M = "GPVTG" Then
Gpvtg = ""
V_counter = 0
Do
M = Mid(urx_buff , Cnt , 1)
Incr V_counter
Incr Cnt
Gpvtg = Gpvtg + M
Loop Until V_counter > 78 Or M = "*"
Exit For
End If
Next
Urx_buff = ""
Cnt = 0
Return
'-------------------------------------------------------------------------------
Extract:
V_counter = 0
L = Len(gpgga)
For I = 1 To L
M = Mid(gpgga , I , 1)
If M = "," Then
Incr V_counter
If V_counter = 1 Then
F_utc_time = I + 1

Elseif V_counter = 2 Then
E_utc_time = I - F_utc_time
F_latitude = I + 1

Elseif V_counter = 3 Then
E_latitude = I - F_latitude

Elseif V_counter = 4 Then
F_longitude = I + 1

Elseif V_counter = 5 Then
E_longitude = I - F_longitude

Elseif V_counter = 7 Then
F_sat_num = I + 1

Elseif V_counter = 8 Then
E_sat_num = I - F_sat_num

Elseif V_counter = 9 Then
F_altitude = I + 1

Elseif V_counter = 10 Then
E_altitude = I - F_altitude
End If

End If
Next
Utc_time = Mid(gpgga , F_utc_time , E_utc_time) : Utc_time = Left(utc_time , 6)
Latitude = Mid(gpgga , F_latitude , E_latitude)
Longitude = Mid(gpgga , F_longitude , E_longitude)
Altitude = Mid(gpgga , F_altitude , E_altitude)
Sat_num = Mid(gpgga , F_sat_num , E_sat_num)

R_k1 = Left(latitude , 2)
S_k1 = Val(r_k1)
Latitude = Mid(latitude , 3 , 7)
S_k2 = Val(latitude)
S_k2 = S_k2 / 60
S_k2 = S_k2 + S_k1
Latitude = Fusing(s_k2 , "#.######")

R_k1 = Left(longitude , 3)
S_k1 = Val(r_k1)
Longitude = Mid(longitude , 4 , 7)
S_k2 = Val(longitude)
S_k2 = S_k2 / 60
S_k2 = S_k2 + S_k1
Longitude = Fusing(s_k2 , "#.######")
N = Val(sat_num)

If S_k2 <> 0 And N > 1 Then
Locate 1 , 1 : Lcd "Latitude=" ; Latitude ; Chr(0) ; " "
Locate 2 , 1 : Lcd "Longitud=" ; Longitude ; Chr(0) ; " "
Locate 3 , 1 : Lcd "Utc_time=" ; Utc_time
Locate 4 , 1 : Lcd "Altitud=" ; Altitude ; "m N=" ; Sat_num
End If
Return
'-------------------------------------------------------------------------------
Rec_isr:
Incr Cnt
Urx_buff = Urx_buff + Chr(udr)
Return








and GSM programme:




$regfile = "m16def.dat"
$crystal = 11059200
$baud = 9600
'$sim

Declare Sub Getline(s As String)
Declare Sub Flushbuf()
Declare Sub Showsms(s As String )


Dim I As Byte , B As Byte
Dim Sret As String * 200 , Stemp As String * 6 , W As Word
Dim S1 As String * 200 , S2 As String * 200



Ddrb.0 = 1
Ddrd.4 = 1

Config Lcdpin = Pin , Db4 = Pinc.4 , Db5 = Pinc.5 , Db6 = Pinc.6 , Db7 = Pinc.7 , E = Pinc.3 , Rs = Pinc.2
Config Lcd = 16 * 2

Cls
Home
Lcd "nEW"
'---------------------------------------------

Lowerline : Lcd "ON Process"
Toggle Portd.4
Portb.0 = 1
Wait 2
Toggle Portd.4
Portb.0 = 0
Wait 4
Toggle Portd.4
Portb.0 = 1
Wait 15
Toggle Portd.4

Print "AT" ; Chr(13)
Wait 1

Print "AT" ; Chr(13)
Wait 1

Print "AT" ; Chr(13)
Wait 1
Print "AT" ; Chr(13)
Wait 1
Print "AT" ; Chr(13)
Wait 1
Print "ATE0" ; Chr(13)
Wait 1



'----------------------------------------------
'sms settings

Cls : Home : Lcd "send sms"
Wait 1
Print "AT+CMGF=1" ; Chr(13)
Wait 1
Print "AT+CMGS=" ; Chr(34) ; "0913322222" ; Chr(34) ; Chr(13)
Wait 1
Print "SIM IS Restarted" ; Chr(26)
Lowerline : Lcd "sent sms1"
Getline Sret
Cls : Lowerline
Lcd Sret
Wait 4

Print "AT+CGATT=1" ; Chr(13)
Getline Sret
' get data from modem
Cls : Lowerline
Lcd Sret
Wait 4
Print "AT+CIPSTART=" ; Chr(34) ; "UDP" ; Chr(34) ; "," ; Chr(34) ; "91.98.32.182" ; Chr(34) ; "," ; Chr(34) ; "8830" ; Chr(34) ; Chr(13)
Getline Sret
Cls : Lowerline
Lcd Sret
Wait 4
Print "AT+CIPSEND" ; Chr(13)
Wait 1
Print Chr(01) ; Chr(02) ; Chr(03) ; Chr(26)
Getline Sret
Cls : Lowerline
Lcd Sret
Wait 4

Print "AT+CIPSEND" ; Chr(13)
Wait 1
Print 123
Getline Sret
Cls : Lowerline
Lcd Sret
Wait 4

Print "AT+CIPSEND" ; Chr(13)
Wait 1
Print "123"
Getline Sret
Cls : Lowerline
Lcd Sret
Wait 4


'--------------------------------------------------


Do
Getline Sret ' get data from modem
Cls : Lowerline
Lcd Sret
Wait 1
I = Instr(sret , ":") ' look for :
If I > 0 Then 'found it
Stemp = Left(sret , I)
Select Case Stemp
Case "+CMTI:" : Showsms Sret ' we received an SMS
' hanle other cases here
End Select
End If

Loop
Flushbuf




End



Sub Showsms(s As String )
Cls : Home
I = Instr(s , ",") ' find comma
I = I + 1
Stemp = Mid(s , I) ' s now holds the index number
Lcd "Number=" ; Stemp
Wait 1

Print "AT+CMGR=" ; Stemp ' get the message
Getline S1
Getline S2 ' header +CMGR: "REC READ","+316xxxxxxxx",,"02/04/05,01:42:49+00"
Cls : Home : Lcd "back sms"
Wait 1
Print "AT+CMGF=1" ; Chr(13)
Wait 1
Print "AT+CMGS=" ; Chr(34) ; "0913333333" ; Chr(34) ; Chr(13)
Wait 1
Print S1
Wait 1
Print S2 ; Chr(26)
Lowerline : Lcd "backed sms1"
Wait 4
Cls : Home
Lcd "remove sms"
Print "AT+CMGD=" ; Stemp ' delete the message
End Sub


Sub Getline(s As String)
S = ""
Do
B = Inkey()
Select Case B
Case 0 'nothing
Case 13 : If S <> "" Then Exit Do ' we do not need this one
Case 10 : If S <> "" Then Exit Do ' if we have received something
Case Else
S = S + Chr(b) ' build string
End Select
Loop
End Sub


'flush input buffer
Sub Flushbuf()
Waitms 100 'give some time to get data if it is there
Do
B = Inkey() ' flush buffer
Loop Until B = 0
End Sub
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top