Using Arduino GSM shield 2 with Adafruit's Ultimate GPS V3

Hey there,

Lately i have been trying to make a GPS tracker that sends the speed and coördinates to a webserver. However, when i started programming i came across the fact that the SoftwareSerial, GSM and GPS library's don't work together. After some research i came across this site : (arduino uno - Simultanous read and read/write on two serial connections - Arduino Stack Exchange), where they claim that is caused by the fact that, in the GPS library is being referred to the SoftwareSerial library, however that is already being used by the GSM (i guess).

I'm working with an Arduino Uno,
this GPS module (https://learn.adafruit.com/downloads/pdf/adafruit-ultimate-gps.pdf)
and this GSM shield (Arduino - Home)

I hope that someone can tell me how to fix this.

Greets,

This is my error-code

Arduino: 1.6.3 (Windows 7), Board:"Arduino Uno"

GSM\GSM3SoftSerial.cpp.o: In function `__vector_3':

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3SoftSerial.cpp:499: multiple definition of `__vector_3'

SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\SoftwareSerial/SoftwareSerial.cpp:227: first defined here

GSM\GSM3SoftSerial.cpp.o: In function `GSM3SoftSerial::spaceAvailable()':

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3SoftSerial.cpp:487: multiple definition of `__vector_4'

SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\SoftwareSerial/SoftwareSerial.cpp:392: first defined here

GSM\GSM3SoftSerial.cpp.o: In function `GSM3SoftSerial::spaceAvailable()':

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3SoftSerial.cpp:487: multiple definition of `__vector_5'

SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\SoftwareSerial/SoftwareSerial.cpp:392: first defined here

collect2.exe: error: ld returned 1 exit status

I hope that someone can tell me how to fix this.

Get a Mega.

Can you explain how to do that, since i have a mega, but in what way do i have to change the code?

but in what way do i have to change the code?

Isn't it obvious? You need to stop using the SoftwareSerial class.

but whenever i get rid of the software-serial library, the gps library starts to fail. but whenever the software-serial library is in it, the gsm library starts to fail.

but whenever i get rid of the software-serial library, the gps library starts to fail. but whenever the software-serial library is in it, the gsm library starts to fail.

That's a real shame.

Too bad we can't help. Perhaps if we could see your code, the story might have a happier ending.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------Libraries-invoegen-----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  #include <SoftwareSerial.h>                                                                 //SoftwareSerial ondersteunt de GPS
  #include <Adafruit_GPS.h>                                                                   //Adafruit_GPS ondersteunt de GPS
  #include <GSM.h>                                                                            //GSM ondersteunt te webmodule

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------Variabelen-invoegen-----------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------GSM-Variabelen------------------------------------------------------------------------------
  #define PINNUMBER ""                                                                    //De pincode van de bijbehorende SIM-kaart                    

  #define GPRS_APN       "GPRS_APN"                                                       //Acces Point Names is bijv. live.vodafone
  #define GPRS_LOGIN     "login"                                                          //Login Naam voor het gprs netwerk
  #define GPRS_PASSWORD  "password"                                                       //Wachtwoord voor het gprs netwerk

  GPRS gprs;                                                                              //GSM Setup 
  GSM gsmAccess;                                                                          //True variabele voor debug-modus
  GSMServer server(80);                                                                   //InternetPort voor het connecten

  const unsigned long __TIMEOUT__ = 10 * 1000;                                            //Timeout in miliseconden


//-------------------------------------------------------------------------------------------GPS-Variabelen---------------------------------------------------------------------------
  HardwareSerial mySerial = Serial1;                                                            //tx = 2, rx = 3
  Adafruit_GPS GPS(&Serial1);
  #define GPSECHO false
  boolean usingInterrupt = false;
  void useInterrupt(boolean);

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------Void-setup----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void setup(){
  Serial.begin(115200);

//----------------------------------------------------------------------------------------------GPS-Setup----------------------------------------------------------------------------
  GPS.begin(9600);
  useInterrupt(true);
  delay(1000);
  
//----------------------------------------------------------------------------------------------GSM-setup----------------------------------------------------------------------------
  boolean notConnected = true;                                                           //Variabele voor of er een client is

  while (notConnected)
  {
    if ((gsmAccess.begin(PINNUMBER) == GSM_READY) &
        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY))
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }                                                                                          //
  Serial.println("Connected to GPRS network");                                               //
  server.begin();                                                                         //Server opstarten

  IPAddress LocalIP = gprs.getIPAddress();                                                //\\
  Serial.println("Server IP address=");                                                     //\\Print het ServerIP in de Seriele monitor
  Serial.println((LocalIP));                                                              //\\
}

//-----------------------------------------------------------------------------------------------GPS-Programmaatjes-----------------------------------------------------------------------------------

SIGNAL(TIMER0_COMPA_vect) {
  char c = GPS.read();
#ifdef UDR0
  if (GPSECHO)
    if (c) UDR0 = c;  
#endif
}

void useInterrupt(boolean v) {
  if (v) {
    // Timer0 is already used for millis() - we'll just interrupt somewhere
    // in the middle and call the "Compare A" function above
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  } else {
    // do not call the interrupt function COMPA anymore
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;
  }
}

uint32_t timer = millis();

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------Void-Loop-------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void loop() {

//-------------------------------------------------------------------------------------------GPS-Data------------------------------------------------------------------------------------------------
if (! usingInterrupt) {
    // read data from the GPS in the 'main loop'
    char c = GPS.read();
    // if you want to debug, this is a good time to do it!
    if (GPSECHO)
      if (c) Serial.print(c);
  }
  
  // if a sentence is received, we can check the checksum, parse it...
  if (GPS.newNMEAreceived()) {
    // a tricky thing here is if we print the NMEA sentence, or data
    // we end up not listening and catching other sentences! 
    // so be very wary if using OUTPUT_ALLDATA and trytng to print out data
    //Serial.println(GPS.lastNMEA());   // this also sets the newNMEAreceived() flag to false
  
    if (!GPS.parse(GPS.lastNMEA()))   // this also sets the newNMEAreceived() flag to false
      return;  // we can fail to parse a sentence in which case we should just wait for another
  }

//------------------------------------------------------------------------------------------------GSM-Data---------------------------------------------------------------------------------------------
  GSMClient client = server.available();



  if (client)
  {
    while (client.connected())
    {
      if (client.available())
      {
        Serial.println("Receiving request!");
        bool sendResponse = false;
        while (char d = client.read()) {
          if (d == '\n') sendResponse = true;
        }
        if (sendResponse)
        {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
//-------------------------------------------------------------------------------------Alle-Berekeningen------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------HTML-Code--------------------------------------------------------------------------------------
          client.println("<html>");
          client.println("<head>");
          client.println("<title>");
          client.println("name removed");
          client.println("</title>");
          client.println("<style>");

          client.println("div {align:center;}");
          client.println("h1 {color:#000000; font-family:Lucida Sans Unicode; text-align:center; font-size:45px;}");
          client.println("h2 {color:#CCCCCC; font-family:Lucida Sans Unicode; text-align:center; font-size:20px;}");
          client.println("table {width:800px; margin-right:auto; margin-left:auto; border-collapse: collapse;}");
          client.println("table, td{border:4px solid #CCCCCC;}");
          client.println("table, th, td {font-size:18px; font-family:Lucida Sans Unicode; color:#000000; text-align:center;}");
          
          
          client.println("</style>");
          client.println("</head>");
          client.println("<h1>");
          client.println("Zonneboot-Team Linde College Data");
          client.println("<hr noshade size=6 width=910 align=center>");
          client.println("</hr>");
          client.println("</h1>");
          
          client.println("<table>");
          client.println("<tr>");
          client.println("<td>Netto energie</td>");
          client.println("<td>");
          client.print(0);
          client.println("</td>");
          client.println("</tr>");
          client.println("<tr>");
          client.println("<td>Opbrengst zonnepanelen</td>");
          client.println("<td>");
          client.print(0);
          client.println("</td>");
          client.println("</tr>");
          client.println("<tr>");
          client.println("<td>Verbruik van motor</td>");
          client.println("<td>");
          client.print(0);
          client.println("</td>");
          client.println("</tr>");
          client.println("<tr>");
          client.println("<td>Snelheid</td>");
          client.println("<td>");
          client.print(("GPS.speed * 1.852"));
          client.print(" Km/h");
          client.println("</td>");
          client.println("</tr>");
          client.println("<tr>");
          client.println("<td>Accustatus</td>");
          client.println("<td>");
          client.print(0);
          client.println("</td>");
          client.println("</tr>");
          client.println("<tr>");
          client.println("<td>Afgelegde afstand</td>");
          client.println("<td>");
          client.print(0);
          client.println("</td>");
          client.println("</tr>");
          client.println("<tr>");
          client.println("<td>Nog te varen afstand</td>");
          client.println("<td>");
          client.print(0);
          client.println("</td>");
          client.println("</tr>");
          client.println("<tr>");
          client.println("<td>Extra GPS Data</td>");
          client.println("<td>");
          client.print(0);
          client.println("</td>");
          client.println("</tr>"); 
          client.println("</table>");
          client.println("<h2>");client.println("Extra GPS data");client.println("</h2>");
          
          client.println("<table>");
          client.println("<tr>");
          client.println("<td>Locatie</td>");
          client.println("<td>");
          client.print(0);
          client.println("</td>");
          client.println("</tr>");     
          client.println("<tr>");
          client.println("<td>Aantal Satellieten</td>");
          client.println("<td>");
          client.print(0);
          client.println("</td>");
          client.println("</tr>");      
          client.println("</table>");
          client.println("</html>");

          delay(1000);
          client.stop();
        }
      }
    }
  }
}

in 2 parts it worked...

This is the errorcode

Arduino: 1.6.3 (Windows 7), Board:"Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Build-opties gewijzigd, alles wordt opnieuw gebuild

GSM\GSM3SoftSerial.cpp.o: In function `__vector_9':

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3SoftSerial.cpp:499: multiple definition of `__vector_9'

SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.cpp:227: first defined here

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions

GSM\GSM3SoftSerial.cpp.o: In function `GSM3SoftSerial::spaceAvailable()':

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3SoftSerial.cpp:487: multiple definition of `__vector_10'

SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.cpp:392: first defined here

GSM\GSM3SoftSerial.cpp.o: In function `GSM3SoftSerial::spaceAvailable()':

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3SoftSerial.cpp:487: multiple definition of `__vector_11'

SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.cpp:392: first defined here

collect2.exe: error: ld returned 1 exit status

I see that you did NOT remove include of the SoftwareSerial header file. Why not?

oh sorry, i forgot to do that…

This is the errorcode without the softwareserial library

Arduino: 1.6.3 (Windows 7), Board:"Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

In file included from GsmWebServerZonneboot.ino:5:0:

C:\Program Files (x86)\Arduino\libraries\Adafruit_GPS/Adafruit_GPS.h:26:32: fatal error: SoftwareSerial.h: No such file or directory

     #include <SoftwareSerial.h>

                                ^

compilation terminated.

and i just checked, but the softwareserial library is still complete in it's folder

You'll need to modify the Adafruit_GPS to not use SoftwareSerial, too.

Could you specify what i have to do with the GPS library to make it work without the softwareserial library?

Could you specify what i have to do with the GPS library to make it work without the softwareserial library?

It's rather obvious, isn't it? Delete the #include statement that includes SoftwareSerial.h. Then, fix all the compiler errors. You'll need to change the SoftwareSerial instance to whichever SerialN instance matches the port you actually connect the GPS to.

Then, register a complaint on the Adafruit forum. It's time that they quit ASSuming that you will use SoftwareSerial to talk to the GPS.