Raspberry Pi With a GSM Module

258

7

Posted

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

    • Space Challenge

      Space Challenge
    • Microcontroller Contest

      Microcontroller Contest
    • Spotless Contest

      Spotless Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments