716

Raspberry Pi the SMS Server Software, BOM & Video Instructions:Video Instruction:

Raspberry Pi the SMS Server

 

Software, BOM & Video Instructions:

Video Instruction:

http://pan.baidu.com/s/1pJkddAN

 

The bill of materials:

01. GPRS Shield 900 1800 MHZ - $4.7

02. USB to serial dongle - $1.5

03. Raspberry Pi computer (preferable model B2 – 512MB RAM)

04. SIM card – ready for sending SMS.

[the serial dongle is required because these shields don't work on direct UART connections]

 

Fig-1: The pin detail after assembly – notice the 5volt & Tx – RX connections.

 

Fig-2: The polarity of the LEDs on PCB – [ the +ve comes from the edge side of the PCB ,where the D1,R1,D4,R3 is written ]

 

Fig-3: The USB to serial device – [ this is just any USB to serial dongle ]

 

Fig-5: Connected to Raspi

 

Fig-6: Connected to Raspi

 

Software: 

$> sudo apt-get update

$> sudo apt-get upgrade

$> sudo apt-get install gammu wammu

 

Testing: Connect the pin detail of the GPRS shield like this.

Pin-2 : +5V : connect to VCC of Dongle

Pin-3 : Ground : connect to GND of Dongle

Pin-14 : Tx : connect to Rx of dongle

Pin-16 : Rx : connect to Tx of dongle

Insert the SIM card into the SIM card jacket.

 

Insert the GPRS shiled into an empty USB slot of the Raspberry Pi computer. 

$> ls /dev/ttyUSB* #the output will tell you where the USB to Serial donlge is mounted.

$> nano .gammurc

[gammu]

port=/dev/ttyUSB0   # enter as per the location

connection=at115200

name=gammu

model=

 

save it by control+o and exit nano. Copy this gammu configuration file to it's default location at /etc/

$> sudo cp .gammurc /etc/gammurc

 

$> gammu --identify

pi@raspi40 /var/www/html $ gammu --identify

Device : /dev/ttyUSB0

Manufacturer : Undefined

Model : unknown (M590)

Firmware : Undefined

IMEI : 355911047632749

SIM IMSI : 404929508997756

pi@raspi40 /var/www/html $

 

That shows the gammu has found the shield and is ready for heavy work now! In case the shiled is not found check for the USB port and retry.

 

Gammu has a beautiful graphical interface – wammu.

$> wammu

Fig-8: Graphical interface of Wammu

Wamm is very light weight program. It can be started on any shell connection on Raspi by entering the following line on the command line.

 

 

SMS server using PHP: There are many thrid party open source PHP SMS server like gammu-php, kalkun etc but here I've built up one simple PHP SMS server in less than 100 words. The output can be seen right on the browser page.

 

Fig-7: Raspberry Pi - SMS server

 

Command line interface: 

$> echo “Hello Guys, how is life?” | gammu --sendsms text +91xxxxxxxxxx

 

PHP program:

Prerequisit:Apache and PHP.

$sudo apt-get install apache2 php5-dev,php5

For running the gammu program the www-data needs super user permission for /usr/bin/gammu.

 

Open the sudousers file in /etc/sudousers and then add the following line below it. 

$> sudo visudo // this command will open the sudouser file in nano editor.

# add the following line

www-data ALL = (ALL) NOPASSWD: /usr/bin/gammu

 

Close nano editor by control+x. Save it and relax !

www-data or the browser is now capable to run the sms.php program.

 

Testing:

http://(ip address of Raspi)/sms.php and the following window will appear.

Fig-7: Raspberry Pi - SMS server

 

Insert the message in less than 200 characters and the destination numbers by comma-separation. You can copy paste in these text box as well. Then press the 'SEND' button and all the SMS will be sent one by one and the delivery report will be appearing below the browser window. The 'OK' in the report shows the SMS is delivered if not look for other reasons. However, sometimes even after appearing 'OK' it takes some time by the cellular network to get them delivered.

 

I've put a delay of 6 second for my network slowness problems. You can change it as per your cellular network conditions.

 

Date:10-09-15 

SMS Server with delivery schedule:

SMS server combined with 'at' command can make the SMS server a SMS scheduler which can schedule your SMS to be sent anytime in the future starting from 1 minute to 10 years time frame.

 

It's simple yet extremely powerful. First we need to install at command and then give execution right to www-data.

 

$> sudo apt-get install at #this will install at commands on Raspi

...

$>sudo visudo

#add the following line

www-data ALL = (ALL) NOPASSWD: /usr/bin/gammu, NOPASSWD: /usr/bin/at

# that's gives permission to www-data as sudo users to run gammu & at.

#save the visudo by ctrl+o and exit by ctrl+x.

...

$>sudo gammu --sendsms EMS your number -text “Hello guys from Bera Here” | at now+10 minutes

will send the SMS in 10 minutes from now.

$>sudo gammu --sendsms EMS your number -text “Hello guys from Bera Here” | at 1430 2>&1

will send an SMS at 2:30 PM and the command will be written to nowhere (2>&1)

http://(your IP address)/sms1.php

 

Fig-9: Raspberry Pi SMS scheduler

[Unfortunately 1 minute is the least scheduled time available with at]

 

However, with now command only one number will be considered for delivery rest all numbers will be discarded.

Eg: now+10 days ; The SMS will be delivered to the first number with a schedule of this time 10 days from now.

Assuming today is 18/10/2014 – 18th October 2014

the expression:

would translate to:

noon

12:00 PM October 18 2014

midnight

12:00 AM October 19 2014

teatime

4:00 PM October 18 2014

tomorrow

10:00 AM October 19 2014

noon tomorrow

12:00 PM October 19 2014

next week

10:00 AM October 25 2014

next monday

10:00 AM October 24 2014

fri

10:00 AM October 21 2014

9:00 AM

9:00 AM October 19 2014

2:30 PM

2:30 PM October 18 2014

1430

2:30 PM October 18 2014

2:30 PM tomorrow

2:30 PM October 19 2014

2:30 PM next month

2:30 PM November 18 2014

2:30 PM Fri

2:30 PM October 21 2014

2:30 PM 10/21

2:30 PM October 21 2014

2:30 PM Oct 21

2:30 PM October 21 2014

2:30 PM 10/21/2014

2:30 PM October 21 2014

2:30 PM 21.10.14

2:30 PM October 21 2014

now + 30 minutes

10:30 AM October 18 2014

now + 1 hour

11:00 AM October 18 2014

now + 2 days

10:00 AM October 20 2014

4 PM + 2 days

4:00 PM October 20 2014

now + 3 weeks

10:00 AM November 8 2014

now + 4 months

10:00 AM February 18 2015

now + 5 years

10:00 AM October 18 2019

now + 10 years

10:00 AM October 18 2024

Note:If you don't specify a time at the command line, at will return the following error message: Garbled time

 

$>sudo atq #will show all the scheduled task with task numbers ready for delivery

$>sudo /var/mail/mail #will show the mail where the last delivery report available.

$>sudo atrm (number) # to delete any scheduled SMS , take help from 'sudo atq'

 

 

S. Bera

Vindhyanagar