locked
SEND/RECEIVE sms from RS232 GSM MODEM RRS feed

  • Question

  • Hello Friends,
    I have got this much till now,

    1) Sending AT commands to Serial port which connects to GSM MODEM, it works well with Hyperterminal.
    2) Sending SMS Message through VB.NET using AT Commands.
    3) Receiving SMS Message through VB.NET using AT Commands.

    But my problem is,
    1) Whenever i send SMS to GSM modem that SMS message has to be pushed to my PC.[this will work if i write a button click event sending AT command to retrieve SMS]
    but i don't want it to happen user event driven.
    GSM modem should automatically send the sms that it receives.(It means our application must keep listening to the port)

    I need help in these points,
    1) How to make GSM MODEM send SMS Message that it receives automatically to RS232 serial port[COM3]
    2) How to listen to a particular port say COM3 for incoming messages.

    i need some help with respect to coding part.
    Thanks in advance.
    Saturday, February 13, 2010 6:26 AM

Answers

  • Move your send code from the command button click event to some other event (you choose).

    Use the SerialPort .DataReceived event to process received messages.  This event then allows you to automatically process data as it is received.  Naturally, you will have to add code to parse these messages appropriately, and display or archive them.

    There have been fairly recent threads on this subject, and there are code examples that you can find via a search engine.  You might want to use the keywords "SMS VB .NET" for example.

    Dick
    Dick Grier. Author of Visual Basic Programmer's Guide to Serial Communications 4. See www.hardandsoftware.net.
    Sunday, February 14, 2010 8:55 PM
  • Thank you Dick Grier.
    I got answers for my queries:
    Hello Friends,
    I have got this much till now,

    1) Sending AT commands to Serial port which connects to GSM MODEM, it works well with Hyperterminal.
    2) Sending SMS Message through VB.NET using AT Commands.
    3) Receiving SMS Message through VB.NET using AT Commands.

    But my problem is,
    1) Whenever i send SMS to GSM modem that SMS message has to be pushed to my PC.[this will work if i write a button click event sending AT command to retrieve SMS]
    but i don't want it to happen user event driven.
    GSM modem should automatically send the sms that it receives.(It means our application must keep listening to the port)

    I need help in these points,
    1) How to make GSM MODEM send SMS Message that it receives automatically to RS232 serial port[COM3]
    2) How to listen to a particular port say COM3 for incoming messages.

    i need some help with respect to coding part.
    Thanks in advance.


    Answers:
    we have to first configure GSM MODEM to send whatever data that it receives to serial port this can be done by this AT COMMAND.
    AT+CNMI=1,2,0,0,0
    then whatever messages that GSM MODEM receives it will push that to serial port/PC.

    Then we can parse that received message(listening) using SERIAL PORT control's Datareceived Event.
    Wednesday, February 24, 2010 3:56 AM

All replies

  • Move your send code from the command button click event to some other event (you choose).

    Use the SerialPort .DataReceived event to process received messages.  This event then allows you to automatically process data as it is received.  Naturally, you will have to add code to parse these messages appropriately, and display or archive them.

    There have been fairly recent threads on this subject, and there are code examples that you can find via a search engine.  You might want to use the keywords "SMS VB .NET" for example.

    Dick
    Dick Grier. Author of Visual Basic Programmer's Guide to Serial Communications 4. See www.hardandsoftware.net.
    Sunday, February 14, 2010 8:55 PM
  • Thank you Dick Grier.
    I got answers for my queries:
    Hello Friends,
    I have got this much till now,

    1) Sending AT commands to Serial port which connects to GSM MODEM, it works well with Hyperterminal.
    2) Sending SMS Message through VB.NET using AT Commands.
    3) Receiving SMS Message through VB.NET using AT Commands.

    But my problem is,
    1) Whenever i send SMS to GSM modem that SMS message has to be pushed to my PC.[this will work if i write a button click event sending AT command to retrieve SMS]
    but i don't want it to happen user event driven.
    GSM modem should automatically send the sms that it receives.(It means our application must keep listening to the port)

    I need help in these points,
    1) How to make GSM MODEM send SMS Message that it receives automatically to RS232 serial port[COM3]
    2) How to listen to a particular port say COM3 for incoming messages.

    i need some help with respect to coding part.
    Thanks in advance.


    Answers:
    we have to first configure GSM MODEM to send whatever data that it receives to serial port this can be done by this AT COMMAND.
    AT+CNMI=1,2,0,0,0
    then whatever messages that GSM MODEM receives it will push that to serial port/PC.

    Then we can parse that received message(listening) using SERIAL PORT control's Datareceived Event.
    Wednesday, February 24, 2010 3:56 AM
  • Hello Mr Ganesh

    I wish to develop an application to send/receive sms from vb.net(2005) application.

    Can you suggest me the source or any suggestion?

    Thanks in advance

    V.L.Patil

    Wednesday, September 8, 2010 10:02 AM
  • Even we are doing  SMS based project  that requires GSM modem.Can you please guide me. 

    Which GSM modem did you use?? Where can we order for GSM modems in India??

    Also is it necessary to do the coding in vb.net??can we do it in java??

     

    Regards,

    Rakshitha.

    Friday, December 24, 2010 9:19 AM
  • Here is a short description of the code required:

    The following table lists the AT commands that are related to the receiving and reading of SMS messages:

    AT command

    Meaning

    +CNMI

    New message indications

    +CMGL

    List messages

    +CMGR

    Read messages

    +CNMA

    New message acknowledgement

    Below shows a simple example that demonstrates how to use GSM/GPRS modem AT commands and your program to read SMS text messages received by a GSM / GPRS modem. The lines in bold type are the command lines that should be sent via your program.  Follow each of these commands with a carriage return character (vbCr). The other lines are responses returned from the GSM / GPRS modem.

    AT
    OK
    AT+CMGF=1
    OK
    AT+CMGL="ALL"+CMGL: 1,"REC READ","+85291234567",,"06/11/11,00:30:29+32"
    Hell0!.
    AT+CMGL: 2,"REC READ","+85291234567",,"06/11/11,00:32:20+32"
    This is a demo of SMS text messaging.

    OK

    Here is a description of what is done in the above example:

    • Line 1: "AT" is sent to the GSM / GPRS modem to test the connection. The GSM / GPRS modem sends back the result code "OK" (line 2), which means there is a connection between the program and the GSM / GPRS modem.
    • Line 3: The command “AT+CMGF” is used to instruct the GSM / GPRS modem to operate in SMS text mode. The result code "OK" is returned (line 4), which indicates the command “AT+CMGF=1" has been executed successfully. If the result code “ERROR” is returned, it is likely that the GSM / GPRS modem does not support the SMS text mode. To confirm, send “AT+CMGF=?" from the program. If the response is "+CMGF: (0,1)" (0=PDU mode and 1=text mode), then SMS text mode is supported. If the response is "+CMGF: (0)", then SMS text mode is not supported.
    • Line 5-9: The command “AT+CMGL” is used to list all SMS text messages in the message storage of the GSM / GPRS modem. There are two SMS text messages in the message storage: " Hell0!” and “This is a demo of SMS text messaging.”  “+85291234567” is the sender mobile phone number. "06/11/11,00:30:29+32" and "06/11/11,00:32:20+32" tell us when the SMS text messages were received by the SMSC. "+32" is the time zone. Note that the unit is a quarter of an hour. So, +32 means GMT+8 hours, since 32 quarters of an hour = 8 hours. "REC READ" indicates both of the SMS text messages have been read before.
    • Line 11: The result code "OK" indicates the execution of the command “AT +CMGL” worked.

    Dick


    Dick Grier. Author of Visual Basic Programmer's Guide to Serial Communications 4. See www.hardandsoftware.net.
    Monday, December 27, 2010 5:36 PM
  • Can I send these commands to GPRS modem and get results of them with visula basic applicaiton that is using SerialPort object. If it is possible how can we do that
    Sunday, January 30, 2011 5:02 PM
  • Sure.  There are a number of online examples that use the SerialPort control (System.IO.Ports.SerialPort) to work with modems.  I have dozens of examples in my book.

    Dick


    Dick Grier. Author of Visual Basic Programmer's Guide to Serial Communications 4. See www.hardandsoftware.net.
    Monday, January 31, 2011 4:44 PM