Send SMS using Windows and any GSM Modem

send-sms-using-windows
Since We have posted how to send SMS using Linux Command line, It will be unfair if we don't do it on Windows OS. So basically We only need a GSM Modem, GAMMU for Windows, and of course Windows 7. My PC has a 64bit architecture, so We will be using the 64bit GAMMU for this tutorial.
 








PREPARATION:

  1. I had a Huawei Mobile Connect Modem lying around in my apartment. Also known as the Globe Tattoo Modem.So let's use it.
    huawei-mobile-connect-globe-tattoo
    You can use any modem or dongle.
    As long as it has a sim card with credit load in it.
  2. Download latest GAMMU for windows (64/x86).
  3. Install or extract the application to your preferred directory. Personally, We always practice that there are no spaces on the directory names. For example, C:\PERSONAL_EXT\Work\Gammu\bin

SETUP GAMMU AS AN ENVIRONMENT VARIABLE

If  you have no idea how to do this, I made a tutorial here on
How to Easily Access any Application from Console.
It is quite intuitive and easy to do. :)

TESTING GAMMU

We have to make sure that Gammu is working well, to do this:
  1. Open the command prompt. (win+r then type cmd)
  2. Type: gammu --version
  3. You should see something like this:
    gammu-version
    Shows we the Gammu version... duh...

Now that Gammu is ready to go, we can now set it to communicate with the GSM Device.
For this, we will need to configure the GAMMURC file properly.

GETTING THE SAMPLE CONFIG FILES

  1. Let's go to our Gammu directory
  2. Open \share\doc\gammu\examples\config
  3. Copy the GAMMURC file to where your gammu.exe file is. (ex. C:\PERSONAL_EXT\Work\Gammu\bin\)
  4. We can also get a Sample here then copy and put the content to the GAMMURC file in the bin folder
Now, if we open the GAMMURC file, you’ll see that there are the [gammu] [gammu1] lines. This means we can setup multiple devices to handle SMS functionalities. But since we are only using 1 device for this tutorial, We will comment out every thing except the ones under the default [gammu] config.

Note:
Having multiple device handlers means we can accommodate different SMS providers. If we are planning on creating something Big, then we should maximize this feature of Gammu.

DETERMINE THE COM NUMBER OF A GSM DEVICE

  1. Right click on My Computer, then click Manage
  2. Go to the Device Manager, and expand the Ports (COM & LPT) secion.
    com-port-lpt-windows
    You should look for something like this...
  3. Take note on what COM#’s your device is using.

DETERMINE THE GSM CONNECTION TYPE

The connection types vary because of the different protocols gammu uses to "talk" to your devices. Please check Gammu's Config Manual to see what your modem’s connection type is. My modem will just use AT19200 connection

SAMPLE GAMMURC FILE

Here is what my gammurc file looks like.

[gammu]

device = COM5:
connection = at19200
; Do not use model configuration unless we really need it
;model = 6110
;synchronizetime = yes
;logfile = gammulog
;logformat = textall
;use_locking = yes
;gammuloc = locfile
;startinfo = yes
;gammucoding = utf8
;usephonedb = yes 
 


SENDING SMS VIA (CMD) COMMAND LINE

Now for the fun stuff!
  1. Open the Command Prompt then type
  2. gammu -config C:\Directory\to\your\gammurc.file sendsms TEXT "recipient#" -text "message"
  3. You will see something like this
    If you see a "500" error message, check your credit balance 
    and the device's reception.

There, we can now call that command dynamically using any programming language we want. :)

Comments

Popular posts from this blog

Terraform: Merge a List ofObjects into One

SMS Notification using Gammu on Linux