Raspberry Pi With a GSM Module

Published

Introduction: Raspberry Pi With a GSM Module

Some time ago I wrote a few paragraphs about using RPI to monitor your property:

https://www.instructables.com/id/Home-Security-Wit...

I promised to write about using GSM "soon", which in this case has taken 5 months.

The reason I think it might be useful in that context (home security) is obvious - there are

still properties without cable internet access, e.g. that is the case with many holiday cottages in Norway where I now live. 30% of them do not even have grid access - I have been thinking about it too which will take much more time (Arduino consumes too much energy as well to propose a reasonable solution).

Today just a short tutorial about using a GSM module to connect RPI to internet via PPP, leaving the "home security" part as that would require a bit more - RPI has just one serial (?), so maybe you should use USB-to-serial converter to attach RFID reader, if you need it.

Step 1: Wiring

I will try the A-GSM module from itbrainpower.net. That is because I have not had time to solder pins to a SIM800L. I promise I will. A-GSM is just an exaggeration for this simple task, I got this as a gift from my colleagues while I was leaving Orange Poland, I feel obliged to run it.

Ok - just follow the picture. I was worried that the Romanian producer does not suggest any TTL level shifter but I measured the voltage and it sends 3V. When you are ready with cables - press modem power switch for a second or two.

Step 2: Checking Board-to-GSM Connection

I hope your SIM card is not PIN protected. In case it is you may check the wiring and your PIN at a time (it might not be 1234 ;-) ):

sudo apt-get install minicom

sudo minicom -D /dev/ttyAMA0 -b 115200

AT

AT+CPIN=1234

I assumed that modem works at 115200 baud. If it is not the case and you want to change it - you can download a Python script from Itbrainpower.net website (RPi_examples-v0.9-2014.09.30.tar) to set the speed, e.g.:

sudo python setSerial.py 9600 115200

Before you run it comment out all agsm.open() lines, I guess this worked fine in the past or on some other Linux versions.

As you can see on the picture - I had to power off/on the GSM module to make it accept the PIN.

Step 3: PPP Config

The content of the step comes from a-gsm-RPI-examples-py-library-based-v1_2.tar downloaded from manufacturers site. Edit and copy-paste the content below (italic) to locations in bold.

/etc/chatscripts/gprs

ABORT BUSY
ABORT VOICE

ABORT "NO CARRIER"

ABORT "NO DIALTONE"

ABORT "NO DIAL TONE"

ABORT "NO ANSWER"

ABORT "DELAYED"

ABORT "ERROR"

ABORT "+CGATT: 0"

"" AT

TIMEOUT 12

OK ATH

OK ATE1

OK AT+CGDCONT=1,"IP","telia"

OK ATD*99#

TIMEOUT 22

CONNECT ""

You might submit your PIN here too (AT+CPIN...). 'telia' is a name of APN, you have to change it to your operators config!

/etc/ppp/peers/a-gsm

connect "/usr/sbin/chat -v -f /etc/chatscripts/gprs -T telia"
/dev/ttyAMA0

115200

noipdefault

usepeerdns

defaultroute

persist

noauth

nocrtscts

local

Here you have to change the APN too. Be sure the speed is what you have checked earlier! That is a source of hard-to-find PPP fails. BTW - Romanians claim the directory is 'pears' (wrong).

Step 4: Running PPP

To connect to the internet you just execute:

sudo pon a-gsm

The trouble might be that you have your RPI connected to the Internet already, so to be sure it works just run this before (smart of Romanians to suggest it!):

sudo route del default

Now you should have access to the Internet via the GSM network. Try to ping an address!

To shut down PPP:

sudo poff a-gsm

If unsuccessful you might need to start PPP in debug mode:

sudo pon a-gsm debug dump logfd 2 nodetach

In my case the mistakes were:

a) not setting APN

b) wrong serial speed !

c) something hanging on /dev/AMA0 - see the "Home Security" tutorial to learn how to free the port !

Step 5: To Do

1) send images of intruders via MMS, maybe more stable than PPP (to be tested)

2) check all this with SIM800L

3) PPP, MMS and SIM800L with Orange PI

Stay tuned!

Share

    Recommendations

    • Water Contest

      Water Contest
    • Clocks Contest

      Clocks Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    4 Discussions

    Hi BoguszJ1, thank you for sharing information. I also plan to use my Rasperry + GSM to protect a house, following you.

    Hi,

    Is it possible to make a setup that auto switches just like mobile? i want to see if my GSM module is connected to data and if not then the data is send via Ethernet port. this is same life in mobile where we switch between wifi and mobile data....

    appreciate your support

    Hey i am following your link but last command used getting error. what should i do.

    i am used sim800l gsm and pi 3.

    Script /usr/sbin/chat -v -f /etc/chatscripts/gprs -T connect.mobilinkworld.com finished (pid 993), status = 0xb

    Connect script failed

    1 more answer

    Hard to say with status only. See into SYSLOG or change -v to -V to get errors on the console, as far as I remember chat options.