Send SMS from a connected device with 3G modem.
Latest commit 1b03bd3 Feb 10, 2014 Marcus Baer Really watch
Failed to load latest commit information.
bin mode changed Jan 15, 2014
lib Better message handling Feb 10, 2014
.gitignore Better message handling Feb 10, 2014
LICENSE Better structured and with bin May 6, 2013 Add corrected read mode Feb 10, 2014
index.js Updated Feb 10, 2014
package.json Update version Feb 10, 2014
smsd.js Really watch Feb 10, 2014


Send SMS from a connected device with 3G modem. This package requires Gammu to send text messages.

Install and setup of Gammu

  1. Install Gammu: sudo apt-get install gammu (in case of trouble try apt-get update first)
  2. Plug in your modem (phone or use stick)
  3. Find your devices port: dmesg | grep tty (e.g. ttyUSB0)
  4. Configure Gammu: gammu-config or see below (mainly configure port, e.g. /dev/ttyUSB0)
  5. Test device configuration: gammu --identify
  6. Setup PIN code for GSM card: gammu --entersecuritycode PIN 1234

Installation for Node.js

npm install sms -g

Setup and Run

Setup your SMS environment in a folder of your choice.

Create config.js and set up like this:

module.exports = {
    "timeout": 30000,
    "patternLang": "en",
    "patterns": {
        "de": {
            "messageSeparator": 'Speicherplatz ([0-9]{1,3}), Ordner "([a-zA-Z]{3,})", ([a-zA-Z\-]{3,}), ([a-zA-Z]{3,})',
            "separatorAttributes": ['messageId', 'folder', 'storage', 'folderName'],
            "bodyDefinition": 'SMS-Nachricht\nSMSC-Nummer[\s ]*: "([0-9\+]*)"\nGesendet[\s ]*: (.*)\nZeichenkodierung[\s ]*: (.*)\nNummer[\s ]*: "(.*)"\nStatus[\s ]*: (.*)\n\n(.*)',
            "bodyAttributes" : ["smsc", "sendDateStr", "encoding", "phoneNumber", "status", "message"]
        "en": {
            "messageSeparator": 'Location ([0-9]{1,3}), folder "([a-zA-Z]{3,})", ([a-zA-Z\- ]{3,}), ([a-zA-Z ]{3,})',
            "separatorAttributes": ['messageId', 'folder', 'storage', 'folderName'],
            "bodyDefinition": 'SMS message\nSMSC number[\s ]*: "([0-9\+]*)"\nSent[\s ]*: (.*)\nCoding[\s ]*: (.*)\nRemote number[\s ]*: "(.*)"\nStatus[\s ]*: (.*)\n\n(.*)',
            "bodyAttributes" : ["smsc", "sendDateStr", "encoding", "phoneNumber", "status", "message"]

where is..

  • timeout: time between two message fetches
  • messageSeparator: regular expression to detect each message and find some attributes
  • separatorAttributes: ordered list of attribute keys, correspondig to "messageSeparator"
  • bodyDefinition: regular expression to find a bunch of attributes from a message
  • bodyAttributes: is the ordered list of attribute keys, corresponding to "bodyDefinition"

Now run smsd in that folder.

Run smsd

smsd has 4 different modes:

  1. a register mode
  2. a render mode
  3. a read mode
  4. a send mode

Calling the reader without parameters is the render mode: after a given timeout SMS messages are fetched from gateway. If there is a new message, all registered applications are called to fetch messages by calling with read mode.


Other command line applications can register to be informed by a call of some command line code:

smsd --register="application --parameter"

Fetch messages with read mode:

smsd --read

Send a message with send mode:

smsd --send --to=+491234567 --message="Hello World"

Phone number has to be led by country code with a leading plus sign, e.g. +42123454389 !

Usage as library

Documentation will come soon...

More on Gammu

For further information on Gammu read

Gammu config example

This is an example for a Gammu configuration. On Windows use port with COM example, adjusted to your system. How you can detect your modem is here

Create gammurc file on Linux like:

  1. ~/.gammurc
  2. /etc/gammurc

On Windows gammurc file is in the same directory as gammu.exe is or in the same directory where you will call gammu. Read more about configuration here.

port = /dev/ttyUSB0
;port= com10:
connection = at115200
;synchronizetime = yes
;logfile = /home/says/gammulog
;logformat = textall
;use_locking = yes
;gammuloc = locfile
;startinfo = yes
;gammucoding = utf8
;rsslevel = teststable
;usephonedb = yes

Test connection with:

gammu --identify

Send a message manually:

gammu sendsms TEXT 0123456789 -text "Hello Foo"