Getting GPS location and transmit over 3G/EDGE/GSM with Arduino

SIMCOM makes a good value SIM5218 chipset for under $100 that allows you to get GPS coordinates using GPRS, connect to a 3G/EDGE/GSM network, record audio and capture video.

It uses AT commands to communicate with the internal systems. AT commands or the Hayes command set is a command language first used for low baud modems in 1981, today it's the standard for modems and network control chipsets and alot of the more modern communications programming command sets are based on this original set of commands.

I used an Arduino to communicate with the SIM5218, here is the serial command function I used to communicate, it's based on a Cooking Hacks serial communication set. The complete sourcecode is at the botton of this article.

On a Raspberry Pi you can easily pipe trough your serial commands straight from the command line using minicom (install using command: sudo apt-get install minicom ), note that the chipset is using 115200 BPS and that you need to ls /dev/ to see what the exact USB serial name is for the chip.

minicom -b 115200 -o -D /dev/tty0

First off lets start by checking if the chip is responding

Let's wait untill we get an OK back

Next insert our 3G simcard PIN code

Delay for about 3 seconds to make sure our PIN is unlocked

Connect to our carrier network using AT+CREG

Connect to our carrier 3G/EDGE/GSM APN (access point) using a provided URL and username/password, we used Mobile Vikings that provide web.be as APN address and web/web as user/pass

Next we setup our AGPS server, Google generously provides us one at supl.google.com:7276

Finally we put the chipset in A-GPS mode and turn it on. The first digit = on/off and the second digit is the GPS mode, 1 = S-GPS (standalon GPS), 2 = A-GPS (assisted GPS) . Standalone GPS works without a carrier or network but it much slower and less accurate indoors. Assisted GPS uses a combination of network towers and GPS calculation servers to give faster results.

We then try to get our GPS location, you need to repeat the process untill you get a valid response

Finally we can send our data using the 3G/EDGE network to a remote server using this command:

This opens a connection with your target server and we can then pipe trough a GET request (with extra parameters) using serial. More info on the HTTP 1.1 header request can be found on the W3 site, section 5

The full Source Code for this project can be found on Github: https://github.com/recyclerobot/nerdlab_gps_device