GSM Shield Door Alarm

I have always wanted to play with attaching an Arduino to a cellular network and play around with sending texts messages. I finally decided that I would find the motivation to buy a GSM shield and learn how it all works via a project to install a sensor on my door so that when the door is opened I would get a text message.

To get started I ordered a GSM shield and antenna from Sparkfun:

https://www.sparkfun.com/products/9607

https://www.sparkfun.com/products/8347

 

I think looked around the internet for some help on getting things setup, and here are a few links I found very helpful:

http://tronixstuff.com/wp-content/uploads/2011/01/sm5100b-at-commands.pdf

Page 125 Section 14.2.3 AT+SIND goes over the different SIND codes and their meanings. This was helpful for me to see what was going on as the modem was booting up and connecting to the network (or not connecting to the network).

 

http://www.smssolutions.net/tutorials/gsm/gsmerrorcodes/

This page is full of useful error codes. Again, this was more just for helping me understand what I could and could not do.

 

http://www.tech-recipes.com/rx/14984/usa-mobile-carriers-break-down-of-network-frequencies-and-phone-compatibility/

This page was super, super useful. When I first applied power to the modem and watched the serial data (follow the link below for how to do that) I kept getting an SIND of 8 instead of 4. I finally found this link to determine which frequencies AT&T used, and then cross referenced the frequencies in the table to the SM5100B AT commands PDF to see what number I needed to program into the modem to set to the correct frequencies (14.2.4 AT+SBAND in the PDF).

 

http://tronixstuff.com/2011/01/19/tutorial-arduino-and-gsm-cellular-part-one/

Finally we have the post that I followed to get familiar with the GSM module. Once I got the modem to successfully get onto the AT&T network things went pretty smoothly. Example 26.3 is what I based my code around to send me a SMS when the door alarm was tripped.

 

 

Here is my setup (remember I’m using Sparkfun’s GSM Shield and not the official Arduino GSM shield):

Untitled Sketch_schem

The door senor I used is a magnetic reed switch that is closed when the door is closed, and opens when the door is opened (reed switch is represented by S1). I have a pull up resistor to bias the line when S1 is open, and when S1 closes R1 prevents excessive current from being sent to ground.

 

 

Untitled Sketch_bb

I used pin 7 on the Sparkfun GSM Shield as the “sense’ line from the magnetic reed switch.

 

The code itself is pretty simple as long as you install the SerialGSM library. One downfall I’ve seen so far using soft serial for communication between the Arduino and the cell modem is that the soft serial can’t keep up with the data transmission on longer strings (i.e. when I sent the Arduino a text message that was 200ish characters the first part of the message showed up correctly in the serial monitor window, but the end of the message was missing characters and had some strange characters).

 

Here is a link to the code on my GitHub.

 

 

 

 

Leave a Reply

© 2014 - Brain Overload. All Rights Reserved. Powered by Wordpress and Design by We Create Web Designs