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.

send at command using Vb

Status
Not open for further replies.

potetojb

Member level 3
Joined
Feb 25, 2006
Messages
63
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
Johor,Malaysia
Activity points
1,931
at command in vb

hello

i want to send at command using vb to mobile phone. can someone help me

thankQ for help
 

at command vb

This depends on how you connect the phone to the computer.
If your fone connects through a serial cable OR you have drivers so that the cell phone is detected as a modem then you can use the MSComm control in VB to connect to the required COM port and send AT commands.
 

vb at command

i use sony ericsson data cable but the cable is USB. i down know i can link the phone to vb or not because i think vb just support serial communicatian. usb is perallel..
 

at command+vb

I have a Samsung E730 and I connect it to the PC using USB cable, The can be detected as a modem.

Hoiw can I send the AT-Commands to it using VB.???

Thanks.
 

at commands vb

If the device is detected as a modem, you need to know which COM port it is attached to.
Go to Device Propeties and check the properties of the detected modem and check which port it connects to.
Then in VB add the MS Comm control, and set the properties.
I suppose you should use the slowest speed and use hardware flow control.
Now send the AT commands like normal ASCII data like MSComm1.Output = "AT"
Hope this helps.
 

send at commands vb6 mscomm input

hello
thank
thedesolatesoul

i use sony ericsson T610. i want read the msg using vb

i find serial data cable
i try to send the at command using vb.. that my program.
but i have problem i dont know why the msg cant display in text.. i thing have some problem.

this program dont error bit just not display the output

can u check the program for me.
i realy new in vb6
Private Sub Command1_Click()
Dim sms As String
Dim buffer$

MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.Handshaking = comNone

MSComm1.PortOpen = True

'echo off
MSComm1.Output = "ATE0" & Chr$(13)

Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")
buffer$ = ""

'Report Mobile Equipment Error ( enable )
MSComm1.Output = "AT+CMEE=1" & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")
buffer$ = ""

'Received read message
MSComm1.Output = "AT+CMGR=1" & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "+CMGR: 1,,159")
buffer$ = ""

sms = MSComm1.Input
Text1.Text = sms

Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")

MSComm1.PortOpen = False



End Sub


if i use hyperterminal the output like this

'if use hyperterminal the command output like below
'AT CMGR = 1
'+CMGR: 1,,159
'07910621000010F5240B910621671663F1000060104222334423A0C2E030088232834E19C8049A06
'9BC2AAF3B87482905569D5E8CC06750A625A0F0AB7C32037B90E62D7D761103B3C4F83C46190B8EE '9E87D7207A1A5E9683CEE97619E41E8741F2F43A4D0785C5F3FA18949E97C96190FBBC0E83DCE230
'485C77CFCB20F739CC9E97C9A0B0FB3C07A5C5F575BB0C729FCB6A50985E6783D2F3B03B0D72A75D
'E8301A1446875D


i dont know how to display mscomm1.input and check the mscomm1.input or output function or not

thank
 

mscomm sms cmgf

have you checked what value you are getting in buffer$?
try single stepping to debug and check what o/p u are getting on each line
 

at commands in vb

Okay potetojb, I've checked your program and there are a few things to modify although its a very well written program.

When you set the InputLen to Zero, that means that the MSComm control will read the whole line at once so you dont need to worry about buffer sizes.

You dont need to send ATE0 i.e. the echo off command.

You also need to send an SMS message format command
i.e. AT+CMGF=1 to see the text messages

When you want to reveive the message using AT+CMGR dont use AT+CMGR=1
because the message numbers dont always start from 1. They could be anything like 800,860 etc.
So first you need to download the whole list of SMS messages using the AT+CMGL command.

Then you need to process the list and get the message number you want from it and then read it.

I've used a Motorola C975 to check this and been able to successfully download the message.

Here's the code. I suppose you only need to change the COM port.

Private Sub Command1_Click()
Dim sms As String
Dim buffer$
Dim MsgNumber(100) As Integer

With MSComm1
.CommPort = 4
.Settings = "9600,N,8,1"
.InputLen = 0
.Handshaking = comNone

.PortOpen = True
End With

'Report Mobile Equipment Error ( enable )
MSComm1.Output = "AT+CMEE=1" & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")

Text1.Text = Text1.Text & vbCr & buffer$
buffer$ = ""

'Set SMS format to Text
MSComm1.Output = "AT+CMGF=1" & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")

Text1.Text = Text1.Text & vbCr & buffer$
buffer$ = ""

'Receive List from Mobile
MSComm1.Output = "AT+CMGL" & Chr$(13)
Do
DoEvents
buffer$ = MSComm1.Input
If buffer$ <> "" Then
Text1.Text = Text1.Text & vbCr & buffer$
List1.AddItem Replace(buffer$, Chr(13) & Chr(10), " ") 'remove all the carriage returns before adding to the listbox
End If
Loop Until InStr(buffer$, "OK")
buffer$ = ""

'Now we have to parse the received list of messages
'This contains messages from the inbox, outbox, etc etc
'My motorola was giving "REC READ" for inbox messages
'For eg: +CMGL: 843, "REC READ", "+923452914470"
J = 0
For I = 0 To List1.ListCount - 1
If InStr(List1.List(I), "REC READ") Then 'This is from the Inbox
MsgNumber(J) = Val(Mid(List1.List(I), 9, InStr(List1.List(I), ",") - 9))
J = J + 1
End If
Next

'Now getting the highest number which will hopefully be the newest SMS
SMSNumber = 0
For I = 0 To J - 1
If MsgNumber(I) > SMSNumber Then
SMSNumber = MsgNumber(I)
End If
Next


'Received read message
MSComm1.Output = "AT+CMGR=" & SMSNumber & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")

Text1.Text = Text1.Text & vbCr & buffer$
Text2.Text = buffer$
buffer$ = ""


MSComm1.PortOpen = False

End Sub




Also check out these sites.
**broken link removed**
http://www.etsi.org/ for standards 300 642
[/url]
 

wait cmgr mscomm.input vb6

hello
thedesolatesoul
thank for your code.


1) i use your program but still problem.have error in

For I = 0 To List1.ListCount - 1


why?..

u use

Dim sms As String

for what. i cant understand.

in the program u dont use sms.

2) i use hyperterminal for test the program i send the
AT+CMGL
OK (the output only OK. u thing this true or not.)

3) i use hyperterminal for read the msg. i send this command.

AT (for check the hypeterminal link on my modem cell phone or not)
OK

AT+CMGF=1 (change to text mode)
OK

AT+CMGR=1 ( read the msg stay in bank 1)
.............
..........
.........
the output have time msg send,the sender phone number and the msg.
i want separate the msg. how can i do..

i realy nead help.
sorry for my bad english
 

vb to send at commands

1) Please add a ListBox to your form. I used it simply so that I could list all the messages in the phone.
Also make Text1 multline (in the properties) and add scrollbars too.

2)When I send AT+CMGL, the result is not OK. Infact, the phone sends a list of all the messages stored in the phone.

3)When I send AT+CMGF=1, I get an error. But when I have the list of messages and I know the numbers of each message then I use AT+CMGF=xxx where xxx is the message number.

In order to separate the message you will have to parse the text. Use INSTR function to find the location of some identifier and then use Left,Mid or Right function to select a part of the text.
 

parse at+cmgl

hello
thedesolatesoul


i saw your post and ur sample code in receiving sms. and it so amazing. i've tried ur code. put into form and run it. but when i clicck the button, respond is not in text format. i'm trying to debug ur code and notice that the message format is already set into text. AT+CMGF=1
what should be the error of this program? is there connection with my device? i am using sony ericsson T610.
please do help me....


johndavediuyan@gmail.com

thanks

Added after 33 minutes:

hello
thedesolatesoul

if im not mistaken, the sample code that u have posted is not not working fine with me coz the respon is like this;


in the listbox: AT+CMGLi
ok


in the textbox:

1AT+CMEE=1111OK111 AT+CMGF=1111OK111 AT+CMGL111OK

1 represent the bold vertical line. which is a space.

is this error? or there something wrong with my device. please help
 

at command dengan vb

thedesolatesoul said:
Okay potetojb, I've checked your program and there are a few things to modify although its a very well written program.

When you set the InputLen to Zero, that means that the MSComm control will read the whole line at once so you dont need to worry about buffer sizes.

You dont need to send ATE0 i.e. the echo off command.

You also need to send an SMS message format command
i.e. AT+CMGF=1 to see the text messages

When you want to reveive the message using AT+CMGR dont use AT+CMGR=1
because the message numbers dont always start from 1. They could be anything like 800,860 etc.
So first you need to download the whole list of SMS messages using the AT+CMGL command.

Then you need to process the list and get the message number you want from it and then read it.

I've used a Motorola C975 to check this and been able to successfully download the message.

Here's the code. I suppose you only need to change the COM port.

Private Sub Command1_Click()
Dim sms As String
Dim buffer$
Dim MsgNumber(100) As Integer

With MSComm1
.CommPort = 4
.Settings = "9600,N,8,1"
.InputLen = 0
.Handshaking = comNone

.PortOpen = True
End With

'Report Mobile Equipment Error ( enable )
MSComm1.Output = "AT+CMEE=1" & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")

Text1.Text = Text1.Text & vbCr & buffer$
buffer$ = ""

'Set SMS format to Text
MSComm1.Output = "AT+CMGF=1" & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")

Text1.Text = Text1.Text & vbCr & buffer$
buffer$ = ""

'Receive List from Mobile
MSComm1.Output = "AT+CMGL" & Chr$(13)
Do
DoEvents
buffer$ = MSComm1.Input
If buffer$ <> "" Then
Text1.Text = Text1.Text & vbCr & buffer$
List1.AddItem Replace(buffer$, Chr(13) & Chr(10), " ") 'remove all the carriage returns before adding to the listbox
End If
Loop Until InStr(buffer$, "OK")
buffer$ = ""

'Now we have to parse the received list of messages
'This contains messages from the inbox, outbox, etc etc
'My motorola was giving "REC READ" for inbox messages
'For eg: +CMGL: 843, "REC READ", "+923452914470"
J = 0
For I = 0 To List1.ListCount - 1
If InStr(List1.List(I), "REC READ") Then 'This is from the Inbox
MsgNumber(J) = Val(Mid(List1.List(I), 9, InStr(List1.List(I), ",") - 9))
J = J + 1
End If
Next

'Now getting the highest number which will hopefully be the newest SMS
SMSNumber = 0
For I = 0 To J - 1
If MsgNumber(I) > SMSNumber Then
SMSNumber = MsgNumber(I)
End If
Next


'Received read message
MSComm1.Output = "AT+CMGR=" & SMSNumber & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")

Text1.Text = Text1.Text & vbCr & buffer$
Text2.Text = buffer$
buffer$ = ""


MSComm1.PortOpen = False

End Sub




Also check out these sites.
**broken link removed**
http://www.etsi.org/ for standards 300 642
[/url]



Can you post code/resource about send/receive sms using vb and at command???
thank you so much
email: thuyphuongvn2010@yahoo.com
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top