How To Integrate Uno with GSM Shield and GPS Module.

Here is what I have:

  1. Arduino Uno
  2. GSM shield - http://arduino.cc/en/Main/ArduinoGSMShield
  3. GPS module (Not Shield).

If I were to only use either the GSM or GPS, it works fine. But if I were to combine both the GSM shield and GPS together, I can’t even compile. I was also reading this http://purposefulscience.blogspot.ae/2013/06/arduino-gsm-shield-tips.html and applied method 2. The compilation error is gone. But I cannot get the GPS data at all.

GSM/GSM3SoftSerial.cpp.o: In function `__vector_5':
/Applications/Arduino.app/Contents/Resources/Java/libraries/GSM/GSM3SoftSerial.cpp:529: multiple definition of `__vector_5'
SoftwareSerial/SoftwareSerial.cpp.o:/Applications/Arduino.app/Contents/Resources/Java/libraries/SoftwareSerial/SoftwareSerial.cpp:321: first defined here
GSM/GSM3SoftSerial.cpp.o: In function `__vector_4':
/Applications/Arduino.app/Contents/Resources/Java/libraries/GSM/GSM3SoftSerial.cpp:522: multiple definition of `__vector_4'
SoftwareSerial/SoftwareSerial.cpp.o:/Applications/Arduino.app/Contents/Resources/Java/libraries/SoftwareSerial/SoftwareSerial.cpp:312: first defined here
GSM/GSM3SoftSerial.cpp.o: In function `__vector_3':
/Applications/Arduino.app/Contents/Resources/Java/libraries/GSM/GSM3SoftSerial.cpp:515: multiple definition of `__vector_3'
SoftwareSerial/SoftwareSerial.cpp.o:/Applications/Arduino.app/Contents/Resources/Java/libraries/SoftwareSerial/SoftwareSerial.cpp:305: first defined here

Below are the codes for GPS only. I did not combine it with the GSM codes so that it is simpler to see. I know that GSM shield uses pin number 2 and 3 just so that you don’t ask me why am using pin number 3 for my GPS. :slight_smile:

/*
 * Show the latitude and longitude and satelite
 * The GPS baud need to be set to 9600
 * Ref: http://arduiniana.org/libraries/tinygps/
 */
#include <SoftwareSerial.h>
#include <TinyGPS.h>
//#include <GSM.h> //uncomment this and you are gonna see a bunch of compilation errors

/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/

TinyGPS gps;
SoftwareSerial ss(3, 4);

void setup()
{
  Serial.begin(115200);
  ss.begin(9600);
  
  Serial.print("Simple TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
}

void loop()
{
  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;

  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (ss.available())
    {
      char c = ss.read();
      // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }
  }

  if (newData)
  {
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    Serial.print("LAT=");
    Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    Serial.print(" LON=");
    Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    Serial.print(" SAT=");
    Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
    Serial.print(" PREC=");
    Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
  }
  
  gps.stats(&chars, &sentences, &failed);
  Serial.print(" CHARS=");
  Serial.print(chars);
  Serial.print(" SENTENCES=");
  Serial.print(sentences);
  Serial.print(" CSUM ERR=");
  Serial.println(failed);
  if (chars == 0)
    Serial.println("** No characters received from GPS: check wiring **");
}

Kindly assist and thank you in advance.

Here is what I have: 1. Arduino Uno

Get a Mega or Leonardo with more than one hardware serial port. Quit using SoftwareSerial to read the GPS, until the idiots that created the GSM3SoftSerial class get their damned act together and use SoftwareSerial instead.