RSS Feed for This PostCurrent Article

Use the .NET SMS Library to Retrieve Phone Settings

Download Source Code

I will describe a way of communicating with your mobile phone using AT commands. Normally, a GSM compatible mobile phone will have a built-in modem, which we can communicate using AT commands. The AT command set should be common among all the handphone manufacturers including Nokia, Sony Ericsson, Siemen, and Motorola, although slight differences exist.

Before we can communicate with the GSM phone, a connection must be established first. The connection can be either serial, bluetooth, or irDA. As long as we can connect to the phone, it is fine.

In this scenario, I established a bluetooth connection with my mobile phone. Firstly, I create a partnership between my laptop and my Nokia mobile phone, and then select the Bluetooth Serial Port service on my mobile phone. The configuration may wary depending on the Bluetooth software and the driver for your modem. If everything is okay, you should be able to see a Bluetooth modem configured in your device manager. Successful configuration will have the following:


Take note that in my configuration, the COM port configured is COM9 and the baud rate is 115200. These settings will be used to connect to the mobile phone.

After the Bluetooth connection is set up, we can use HyperTerminal to try to send AT commands to make sure the connection is okay.



As you can see, AT commands start with the word “AT”. E.g., “ATE1” means echo the command typed locally, “AT+CGMM” displays the handphone model, and “AT+CSCA?” displays the SMSC configured in the mobile phone.

If everything is okay now, you can use the sample code attached in this blog to retrieve various handphone settings. The results will be similiar to the screenshot displayed below. Take note that different handsets may support different AT command sets. Certain AT commands may not be available in certain handsets.


The code in the solution is quite straightforward. It makes use of the open source SMS library to retrieve various phone configurations by sending AT commands. You can read the list of the APIs available in the documentation and sample provided.

If cboComPort.Text = String.Empty Then
MsgBox(“COM Port must be selected”, MsgBoxStyle.Information)
End If

Dim oGsmModem As New GSMModem

oGsmModem.Port = cboComPort.Text

If cboBaudRate.Text <> String.Empty Then
oGsmModem.BaudRate = Convert.ToInt32(cboBaudRate.Text)
End If

If cboDataBit.Text <> String.Empty Then
oGsmModem.DataBits = Convert.ToInt32(cboDataBit.Text)
End If

If cboStopBit.Text <> String.Empty Then
Select Case cboStopBit.Text
Case “1”
oGsmModem.StopBits = Common.EnumStopBits.One
Case “1.5”
oGsmModem.StopBits = Common.EnumStopBits.OnePointFive
Case “2”
oGsmModem.StopBits = Common.EnumStopBits.Two
End Select
End If

If cboFlowControl.Text <> String.Empty Then
Select Case cboFlowControl.Text
Case “None”
oGsmModem.FlowControl = Common.EnumFlowControl.None
Case “Hardware”
oGsmModem.FlowControl = Common.EnumFlowControl.RTS_CTS
Case “Xon/Xoff”
oGsmModem.FlowControl = Common.EnumFlowControl.Xon_Xoff
End Select
End If

Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try

txtRevision.Text = oGsmModem.Revision
Catch ex As Exception
txtRevision.Text = “Not supported”
End Try

txtIMSI.Text = oGsmModem.IMSI
Catch ex As Exception
txtIMSI.Text = “Not supported”
End Try

txtIMEI.Text = oGsmModem.IMEI
Catch ex As Exception
txtIMEI.Text = “Not supported”
End Try

txtModel.Text = oGsmModem.PhoneModel
Catch ex As Exception
txtModel.Text = “Not supported”
End Try

txtManufacturer.Text = oGsmModem.Manufacturer
Catch ex As Exception
txtManufacturer.Text = “Not supported”
End Try

txtSMSC.Text = oGsmModem.SMSC
Catch ex As Exception
txtSMSC.Text = “Not supported”
End Try

Dim rssi As Rssi = oGsmModem.GetRssi
txtSignal.Text = rssi.Current & ” of “ & rssi.Maximum
Catch ex As Exception
txtSignal.Text = “Not supported”
End Try

Dim storages() As Storage = oGsmModem.GetStorageSetting
Dim i As Integer
txtSupportedStorage.Text = String.Empty
For i = 0 To storages.Length – 1
Dim storage As Storage = storages(i)
txtSupportedStorage.Text += storage.Name & “(“ &_
storage.Used & “/” & storage.Total & “), “
Catch ex As Exception
txtSupportedStorage.Text = “Not supported”
End Try

Dim loc As Location = oGsmModem.GetLocation
txtLocation.Text = “Cell Id: “ & loc.CellID & _
“, MNC: “ & loc.MNC & “, MCC: “ & _
loc.MCC & “, LAI: “ & loc.LAI
Catch ex As Exception
txtLocation.Text = “Not supported”
End Try

txtPhoneNumber.Text = oGsmModem.MSISDN
Catch ex As Exception
txtPhoneNumber.Text = “Not supported”
End Try

Dim battery As Battery = oGsmModem.GetBatteryLevel
txtBattery.Text = battery.BatteryLevel & “/” & _
battery.MaximumLevel & “(Charging: “ &_
battery.BatteryCharged & “)”
Catch ex As Exception
txtBattery.Text = “Not supported”
End Try

Trackback URL

RSS Feed for This Post12 Comment(s)

  1. eklim | Sep 22, 2007 | Reply

    Hi there,

    I try to download the source for the atsms file in your website but the file is not available. Can you check it out?


  2. thoughtworks | Sep 23, 2007 | Reply

    I just attached the code for this blog.

    To download the SMS library, you will need to register using your email first.

  3. Prashant | Oct 16, 2007 | Reply

    Hi there,

    Could you me what are the phones does this Library supports


  4. admin | Oct 17, 2007 | Reply

    I am revamping the library for version 2.0 and is compiling a list of of phones tested to be released soon. stay tuned.

  5. Prashant | Oct 21, 2007 | Reply

    hi there,
    When I connected my phone with USB, and i’m not able to get phone settings by demo application. Is it possible to make it compatible with USB or do we need to use SUB Serial converter device?

  6. PRT | Oct 30, 2007 | Reply

    I’m using serial cable to connect my phone, do i need to install modem drivers for my phone or Liabrary directly interact with phone from Servial Cable ??

  7. admin | Oct 31, 2007 | Reply

    Refer to the post at

    Make sure you can connect to your phone using HyperTerminal.

  8. Samim | Dec 15, 2007 | Reply

    Can AT commands be used with mobiles that dont have GSM modems.?

  9. vishal khade | Sep 22, 2008 | Reply

    I want to use my code for fatching phone number & send sms using & detect my phone nokia6233.
    Pls help me to solve this problem.

  10. Allwin | Nov 20, 2008 | Reply

    The Open Source is not working properly. Help me.

    When I click the Send Button

    It gives the Error msg like

    Error sending message to . Error sending SMS message: Object reference not set to an instance of an object.

  11. Milton Suen | Apr 17, 2009 | Reply

    Thanks for sharing your sample code, will using try to test it using my Mobile phone 🙂

  12. Vineet Verma | Nov 3, 2009 | Reply

    I want to send SMS through my website. I have some codes which are running well on one computer but when I am using the same codes on my server it is not working can you help me.

1 Trackback(s)

  1. From Sending SMS through WaveComm GSM/GPRS Modem | | Sep 24, 2007

Sorry, comments for this entry are closed at this time.