Working with GPS and GSM on Arduino–Part 1 of 2 (SIM908)


Part 1:  Getting the GSM working

One of the projects I’m undertaking is a remote GPS tracker for my vehicle.

True, you can purchase these in the 30 dollar range from Deal Extreme if you search vehicle trackers.  However, I did see questions regarding temperature and stability.  And one of the worries for me is the websites used for tracking are individually controlled by small companies in China (which could go out of business at any moment).

With that said, GPS and GSM combo units from popular sites such as SparkFun, AdaFruit or CanadianRobotics are likely to run in the 100$ area.  An alternative, is to use a unit such as a SIM908 module at ElectroDragon for 42$, which is a little more affordable and matches my cheap “I’m just learning, I’m going to break it, I don’t want to spend a lot on it” period in my arduino timeline.

What you need:

  • A sim card
  • You will likely want a sim card size changer
  • You will need an Arduino, I used a Uno for this
  • The SIM908 module

The good news:

The bad news:

  • Arduino wise, there is no documentation
  • The pinout provided on ElectroDragon is wrong (it shows a 6 pin SIM908 breakout, where they actually shipped a 10 pin SIM908 breakout)


So first, before reading any further, I have to caution.  I’m not an electrical engineering type.  And I don’t normally work with raw items very often.  With that said, I’ve managed to get the SIM908 to work properly for me using the instructions below.

Restarting the SIM908

When you restart the unit or the Arduino, you may see the blinking red NET LED change to a solid red “I’m going to ignore you” LED.  When this happens, hold the reset button on the SIM908, press and release the reset button on the Arduino, and then release the SIM908 reset button.  This seems to move me to a blinking red NET light more often.

Pin-out Method:


Sample Code – Version 1.0 – GSM Only:

Get it from Github.

Unfortunately, when I purchased the unit, I missed that it came without antennas.  This means I can’t confirm the AT commands and network connectivity until part 2.  For this one, I will include code that will have you up and running from a GSM perspective, with this unit.

I found code written here, and reworked it to create a basic SIM908 GSM library.  GPS is pretty much ready, but you will see it in part 2 (where we finalize the code, and finalize the design).

// Based on the 900 sim on by Alejandro Gallego 
// Reworked from from Serial to Software Serial and reformulated for GPS by Lloyd Summers

#include <SoftwareSerial.h>

int txPin = 11;
int rxPin = 10;
int modGSMPin = 8;
int modGPSPin = 7;
int pinDelay = 3000;
int8_t answer;

char aux_str[30];
char phone_number[] = "4036900707";

SoftwareSerial myGSM(rxPin, txPin);

void setup() {

  // put your setup code here, to run once:
  pinMode(txPin, OUTPUT);
  pinMode(rxPin, INPUT); // used to turn on and off GSM
  pinMode(modGSMPin, OUTPUT);
  pinMode(modGPSPin, OUTPUT);



  Serial.println("Connecting..."); // checks for connection I believe
  while ((sendATcommand("AT+CREG?", "+CREG: 0,1", 500) ||
          sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0);
  // 0 = not registered, not searching
  // 1 = registered on home network
  // 2 = not registered, but searching
  // 3 = registration denied
  // 4 = unknown (out of coverage?)
  // 5 = roaming, registered
  // 6 = SMS only, home network
  // 7 = SMS only, roaming
  // 8 = EMS
  // 9 = CSFB not preferred, home network
  // 10 = CSBFB not preferred, roaming  

  sendATcommand("AT+CREG=?", "OK",1000); // verifies network list
  sendATcommand("AT+GSN","OK",5000); // IEMI
  sendATcommand("ATX4","OK",5000);   // Listen for dialtone + busy signal when dialing


  sendSMS("This is a test","4036900707"); // Test SMS


void loop() {
  // put your main code here, to run repeatedly:


void hangUp() {
  sendATcommand("ATH", "OK", 3000);

void sendSMS(char *message, char *number) {
  Serial.println("Sending SMS...");
  sendATcommand("AT+CMGF=1", "OK", 1000); // prep SMS mode
  // sprintf(aux_str,"AT+CMGS=\"%S\"", number);  
  // answer = sendATcommand(aux_str,">", 2000);
  answer = sendATcommand("AT+CMGS=\"4036900707\"","OK",1000);

  if (answer == 1) {
    // myGSM.println(message);
    myGSM.println("Test message.");
    answer = sendATcommand("", "OK", 20000);
    if (answer == 1) {
    } else {
  } else {
    Serial.print("Error ");
    Serial.println(answer, DEC);

void dial(char *number) {
  Serial.println("Dialing phone number...");
  sprintf(aux_str, "ATD%s;", number);
  sendATcommand(aux_str, "OK", 10000); // dial

void powerOnGSM() {
  uint8_t answer = 0;

  // check if the module is started
  answer = sendATcommand("AT", "OK", 5000);

  if (answer == 0) {
    // Send power on pulse
    digitalWrite(modGPSPin, LOW);
    digitalWrite(modGSMPin, HIGH);
    //digitalWrite(modPin, LOW);

    // wait for answer
    while (answer == 0 ) {
      answer = sendATcommand("AT", "OK", 2000);

int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout) {
  uint8_t x = 0, answer = 0;
  char response[100];
  unsigned long previous;
  memset(response, '\0', 100); // initalize string

  while (myGSM.available() > 0) {; // clears the buffer

  // Serial.println(ATcommand);

  x = 0;
  previous = millis();

  do {
    if (myGSM.available() != 0) {
      response[x] =;
      if (strstr(response, expected_answer) != NULL) {
        answer = 1;
  } while ((answer == 0) && ((millis() - previous) < timeout));

  return answer;


Now, when the code moves to part 2, we need to actually close the Software Serial connection to GSM in order to switch to GPS.  The commands we will be using will be:

  seqSend("AT+CGPSPWR?");    // what power mode are you?  
  seqSend("AT+CGPSPWR=1");   // power on
  seqSend("AT+CGPSTATUS=?");   // test command, what modes are supported
  seqSend("AT+CGPSSTATUS?"); // status, replies: Location Unknown, Location Not Fix, Location 2D Fix, Location 3D Fix
  seqSend("AT+CGPSINF=0");   // get location, Response:  mode,long,lat,alt,utc,ttff,num,speed,course


16 thoughts on “Working with GPS and GSM on Arduino–Part 1 of 2 (SIM908)

  1. The SIM908 module has 2.8V pins at the data interface side. Connecting the SIM908’s inputs directly to Arduino’s 5V outputs will certainly lead to SIM908 pin damage sooner or later. It’s recommended to use level converters or at least voltage dividers with those pins. Also VDD must be connected to an external 5V and preferably 2A or more power supply. Connecting VDD to Arduino’s 3,3V makes no sense, even if it seems to work at first (MIC29302BU regulator will be working off specs). Connecting VDD to Arduino’s 5V may also work but will let SIM908 prone to random resets and malfunctioning. Remember Arduino’s 5V output can supply less than 1A and SIM908 alone has peaks as high as 2A during GSM/GPRS transmissions. A big electrolytic capacitor (1000 to 4700uF) installed across VDD/GND pins may minimize the problem. All that being said I advise not to follow the connection diagram on this page as it is presented.

    1. FYI I’m not ignoring the comments you submitted. Just taking a bit to get to them. Some very good points and it could be my error for taking the pcb specs from the company in China (what they had at the time) without validating it further.  I will review the below against the custom SIM908‎ pcb from ED. And validate the info before changing the article. I don’t want to recommend adding a capacitor if it’s either already on the board, not recommended by ED, and not validated to work properly by myself (its just a precaution – not that I don’t trust you). But if it makes good sense with their PCB as configured I’ll be happy to add it. Same with voltage changes provided I validate it. ‎ This is a *really* old article so it’ll be awhile before I get back to it :)‎ With that said it’s been working without issue for 8+? months as configured in the article per ED’s specs – so I’m hesitant to change anything without looking closer. I’ve actually moved onto Navspark since for GPS tracking. ‎

      1. Hi Lloyd. I have also been working on navspark-GL for GPS tracking. And was trying to connect GSM SIM 900 to it, but the code doesn’t upload and shows error- ‘The code can’t upload for Navspark-GL’ I’d really appreciate some help.

    2. With that all said, if you have posted up an article somewhere with it validated as working, I’d love to link to it in this article for people.

  2. Hi, when it will be posted the part 2 of this program. the one for the gps? how do i make it to pass the pin number from the sim card? thanks.

    1. PIN 7 & 8 weren’t connected to anything on the Arduino side. On the GPS side it was 10 and 11. But I didn’t use the GPS much (I use navspark for most of my GPS needs). With that said, you might be able to get better information these days from

Leave a Reply to Doaa Sawaftah Cancel reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.