[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


Sending SMS from VB through Nokia 6310i with serial data cable

Posted on 2004-10-16
Medium Priority
Last Modified: 2013-12-09
Ok, i have read a questions / answers about what to type for the at commands and using MSCOMM object to talk to the nokias modem..

I can manually send an sms using hyper terminal no probs.. and XP can query the Nokia Modem and give me good results...


I drop the MSCOMM object in a form and then do the simple code as follows:

MSComm1.CommPort = 1
'MSComm1.InputLen = 0
MSComm1.Settings = "9600,N,8,1"
MSComm1.PortOpen = True
MSComm1.Output = "AT" & vbCrLf

'------------- at this point i wait for the modem to report back "OK"
'-                BUT it never does..  nothing happens at this point.
    Debug.Print MSComm1.CommEvent & vbCrLf      '------- ALWAYS returns 0 (zero)
loop Until InStr(buffer$, "OK" & vbCrLf)

'----------- This part i typed in manually in hyperterminal and it works fine...  but my prog never gets this far as above is in a loop.
MSComm1.Output = "AT+CMGF=1" & Chr$(13)
'MSComm1.Output = "AT+CNMI=3,3,2" & Chr(13)
MSComm1.Output = "AT+CMGS=" & "+447834871851" & Chr$(13)
MSComm1.Output = "HeartBeat from WWW1: Server Ok" & Chr$(26)
'MSComm1.PortOpen = False
Label1.Caption = MSComm1.Input

Does anyone know off the top of their head if there is something i am doing wrong?

Thanks in advance
Question by:Cybordax
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1

Accepted Solution

SergeiKo earned 1000 total points
ID: 12340736
Hello, Cybordax.

Try to handle responses from mode as events.

From MSDN:
Event-driven communications is a very powerful method for handling serial port interactions. In many situations you want to be notified the moment an event takes place, such as when a character arrives or a change occurs in the Carrier Detect (CD) or Request To Send (RTS) lines. In such cases, use the MSComm control's OnComm event to trap and handle these communications events. The OnComm event also detects and handles communications errors. For a list of all possible events and communications errors, see the CommEvent property.

Pay attention to
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
Private Static Sub MSComm1_OnComm() function.

Hope the sample below will help you.

Option Explicit

Private Sub Command1_Click()
    Call Disconnect
    Call Connect
    Call Send("AT")
    Call Send("ati")
    Call Send("ati3")
End Sub

Function Connect()
    If MSComm1.PortOpen = False Then
        MSComm1.CommPort = 3
        MSComm1.Settings = "115200,N,8,1" ' 115200 baud, no parity, 8 data, and 1 stop bit.
        MSComm1.InputLen = 0
        MSComm1.RThreshold = 1
        MSComm1.SThreshold = 1
        MSComm1.PortOpen = True
    End If
End Function

Function Disconnect()
    If (MSComm1.PortOpen = True) Then
        MSComm1.PortOpen = False
    End If
End Function

Function Send(str As String)
    MSComm1.Output = str & vbCrLf
End Function

Private Static Sub MSComm1_OnComm()
    Select Case MSComm1.CommEvent
       ' Events
        Case comEvReceive   ' Received RThreshold # of characters
            Dim buffer As String
            buffer = MSComm1.Input
            If buffer <> "" Then
                Debug.Print ">> " & buffer
            End If
    End Select
End Sub


Author Comment

ID: 12341733
I will give that a go and get back to you...

Got back LATE from work tonight, so i WILL let you know the following day...

Thanks for the response dude...


Author Comment

ID: 12351714
Ok, i tried what you had suggested, and still no joy, mate...

I nothing displayes in the debug window...

I can confirm the data cable is recognised by 6310i as it says data accessory connected.
i can confirm PC can see the phone and recognise it on COM1 as Hyper terminal lets me connect, send sms etc...

but VB does not like it....

I did exact coding you typed in...  and changed the send calls to send an sms etc....

i am confused!  lol

Any more help you could provide would be most greatly appreciated!

Thanks in advance
Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

LVL 13

Assisted Solution

imarshad earned 1000 total points
ID: 12355524
>>MSComm1.Output = "AT+CMGF=1" & Chr$(13)
>>'MSComm1.Output = "AT+CNMI=3,3,2" & Chr(13)
>>MSComm1.Output = "AT+CMGS=" & "+447834871851" & Chr$(13)
>>MSComm1.Output = "HeartBeat from WWW1: Server Ok" & Chr$(26)
>>'MSComm1.PortOpen = False
>>Label1.Caption = MSComm1.Input

If this is the code you are using to send the SMS then it will not do the job for you..... You must insert some delay before sending the Modem the next command.....
Here is one way i.e by using Sleep......

MSComm1.Output = "AT+CMGF=1" & Chr$(13)
sleep 500           '0.5 seconds or 500 milliseconds
MSComm1.Output = "AT+CMGS=" & "+447834871851" & Chr$(13)
sleep 500
MSComm1.Output = "HeartBeat from WWW1: Server Ok" & Chr$(26)
sleep 500
Label1.Caption = MSComm1.Input

also try to change the value to 1000 (ms) if it is not working.......and declare sleep as

Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Author Comment

ID: 12355928
Ok, my friend, i will give that a go and get back to you.....

I have to be doing something REALLY stupid....  i did not imagine it to be this....  annoying to set up simple connection to a nokia modem....

Thanks again for your help so far...

Take care dude

Expert Comment

ID: 12356558
Hello, again.

I have some thoughts:
 - try to set RThreshold = 1 and SThreshold = 1 in the setup component properties;
 - be sure you use your port number CommPort = 1 in your case;
 - in Settings you should use the same data rate as modem: 9600 or 115200 or ... . You can get modem's data rate with
   command AT+IPR? and set with command AT+IPR=115200 (to 115200 for example),
   or better choose the same data rate you choose with hyperterminal;
 - try to debug to be sure, that AT command was sent to modem.

Hope this help.

And keep patience when you are trying. If at first you don't succeed, think and try again. :-)


Author Comment

ID: 12390499
Sorry, I have been v busy for a few days at work....

I will try what you advised, but i know i have set the same baud rate etc as hyperterminal....

I will get back to you

Thanks again
LVL 13

Expert Comment

ID: 12824203
I think the suggestions by SegeiKo and imarshad can solve this problem. But the asker never got back to the Question meaning either he got it working or wasnot hoping for an answer....... If you donot want to Split then still it should be Paq'ed rather then deleted.....


Author Comment

ID: 12830982
Hello to all..

Mucho apologies for not getting back, but since the post of the question, have been too busy to continue with my little project....

I still did not get it to work.... very confusing....

The responses by SegeiKo and imarshad  were much appreciated ....  did not get much of a chance to implement and expirement with the suggestions though....

I could split the answers, but I still do not know, and wont be able to find out if their suggestions had worked...  not for a while anyway....  what is  Paq'ed  all about?
LVL 13

Expert Comment

ID: 12832000
PAQ --------> Previously Asked Questions

If a question is PAQ then all the comments that have been made by the Experts are retained. But if a question is deleted then all the comments are deleted and the Question is also deleted. Since there was some useful knowledge in the posts so I wont like to let the Question be deleted.

LVL 20

Expert Comment

ID: 12893609
Leaving it open for a few more days.... but do not make them too much :)


Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

MAC Filtering: MAC filtering is like handing a list of names to a doorman. If someone comes to the door and mentions a name, this name is checked by the doorman on his list and granted or denied access by this. This means that if someone menti…
This article is a step by step guide on how to create a basic PTP link using Ubiquiti airOS devices. This guide can be used on the following Ubiquiti AirMAX devices. Nanostation, Bullets, AirBridge, Nanobeam, NanoBridge to name a few. Please review …
This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question