GPS and GSM Module conflicts?

Hello all,

Basically I want the Arduino to SMS it’s lat and long, but I am really struggling to get them to work in tandem with each other. It seems the GSM module ‘knocks off’ the GPS shield when it initialises. I am using the Sparkfun GPS Shield and the Cellular Shield with SM5100B. I have the GPS module set in the ‘UART’ switch position for normal operation so that it uses pins 0 and 1 for rx and tx so as not to conflict with pin 2 and 3 used by the GSM shield.
If I comment out the:
cell.begin(9600);
cell.Verbose(true);
cell.Boot();
cell.DeleteAllSMS();
cell.FwdSMS2Serial();
in the setup, I get the coordinates perfectly.

Any ideas would be much appreciated. I am pretty stumped to say the least!

#include <SPI.h>
#include <TinyGPS.h>
#include <SerialGSM.h>
#include <SoftwareSerial.h>

SerialGSM cell(2,3);
String message;
String sender;

//Pins to communicate with the GPS module
#define RXPIN 0
#define TXPIN 1
#define GPSBAUD  4800

TinyGPS gps; //Create an instance of the TinyGPS opject.
SoftwareSerial uart_gps(RXPIN, TXPIN); //Intialise the NewSoftSerial Library to the pins above.
void getgps(TinyGPS &gps);

boolean sendonce=true;
void setup(){  
  uart_gps.begin(GPSBAUD);
 Serial.println("");
 Serial.println("GPS Shield QuickStart");
 Serial.println("       ...waiting for lock...           ");
 Serial.println(""); 
    delay(30000);
 Serial.begin(9600);

  cell.begin(9600);
  cell.Verbose(true);
  cell.Boot();
  cell.DeleteAllSMS();
  cell.FwdSMS2Serial();
}


void loop()
{
  
// GPS LOOP START  
  while(uart_gps.available())     // While there is data on the RX pin...
  {
      int c = uart_gps.read();    // load the data into a variable...
      if(gps.encode(c))      // if there is a new valid sentence...
      {
        getgps(gps);         // then grab the data.
      }
  }
// Define the variables that will be used
  float latitude, longitude;
// Then call this function
  gps.f_get_position(&latitude, &longitude);
//GPS LOOP FINISH
  
  if (cell.ReceiveSMS())
  {
//	 Serial.print("Sender: ");
//	 Serial.println(cell.Sender());
//	 Serial.print("message: ");
	 Serial.println(cell.Message());
   message = cell.Message();
   sender = cell.Sender();
   Serial.print("And the sender is.... ");
   Serial.println(sender);
   Serial.print("Lat: ");
   Serial.println(latitude,5);
     
   cell.DeleteAllSMS();
  }
}

// The getgps function will get and print the values we want.
void getgps(TinyGPS &gps)
{
  // To get all of the data into varialbes that you can use in your code, 
  // all you need to do is define variables and query the object for the 
  // data. To see the complete list of functions see keywords.txt file in 
  // the TinyGPS and NewSoftSerial libs.
  
  // Define the variables that will be used
  float latitude, longitude;
  // Then call this function
  gps.f_get_position(&latitude, &longitude);
  // You can now print variables latitude and longitude
  Serial.print("Lat/Long: "); 
  Serial.print(latitude,5); 
  Serial.print(", "); 
  Serial.println(longitude,5);
  delay(10000);
}

If I comment out the ... in the setup, I get the coordinates perfectly.

You get them where?

SoftwareSerial uart_gps(RXPIN, TXPIN); //Intialise the NewSoftSerial Library to the pins above.

SoftwareSerial should not be used on the hardware serial pins.

 Serial.println("");

Especially when Serial is using the same pins.

Thanks for the reply.

Sorry, I get the coordinates outputting to the Serial Monitor. That's how I assume the values will be there for me to use in variables etc to input into an SMS message later.

I am very new to this so can you elaborate on what I can try to fix the issue, or am I a million miles from getting something working? I appreciate your input.

wrighty

If you connect the GPS to pins 0 and 1, the data is going from the GPS directly to the PC. You have no idea whether the Arduino also read the data correctly, or not. So, your assumption is not correct.

I am very new to this so can you elaborate on what I can try to fix the issue

Needle nose plies, wire, solder, and a soldering iron. Bend some of the shield pins (the ones involved in serial communication) so they don't actually plug into the Arduino. Then, solder wires to those pins, and connect them to pins that the shields don't actually use.

Note, shield designers: Quit expecting specific pins to be available for serial. Provide jumpers so ANY pins can be used.

Thanks again for the tip. I have done what you suggested. Still having problems mind, but maybe a step closer. :blush:

wrighty

OK, still struggling so let me rephrase the question (and I have searched around for the answer to this but can't find a relevant solution):

I can get both shields working fine on their own, but as soon as I stack them and try and intertwine the code, no longer works. I am sure there are no pin conflicts as I have now bent out pins 2 and 3 on the GPS shield and patched them through to pins 6 and 7 (thanks PaulS).

Any more suggestions??

Thanks

wrighty

but as soon as I stack them and try and intertwine the code, no longer works.

How much memory (SRAM, not FLASH) do you have when the intertwined code is loaded?

http://playground.arduino.cc/Code/AvailableMemory

Running at 902 on boot, so I'm guessing it's not a memory issue?

wrighty

 Serial.println("");
 Serial.println("GPS Shield QuickStart");
 Serial.println("       ...waiting for lock...           ");
 Serial.println(""); 
    delay(30000);
 Serial.begin(9600);

Serial.begin() needs to be called BEFORE Serial.print().

Mano eu fiz um código que funciona, e faz a validação da mensagem recebida, eu ainda estou com problema de ler o gps usando a biblioteca do Gps Veja abaixo o meu código

#include "SIM900.h"
#include "sms.h"
SMSGSM sms;
#include <SoftwareSerial.h>
SoftwareSerial SerialGprs(2,3);
char smsbuffer[160];
char Numero[14];
char n[20];
boolean started = false;

//Aqui eu iniciou todas as funções e verifico se o modulo está disponivel para funcionar
void setup() {
  Serial.begin(9600);
  Serial.println("Iniciando aguarde...");
  SerialGprs.begin(4800);
  delay(9000);
  if(gsm.begin(2400)){
    Serial.println("\nstatus=READY");
    started = true;
    Serial.println("O modulo de GPRS iniciou com sucesso!");
  }else{ 
    Serial.println("\nstatus=IDLE");
  }
  
}

//Aqui vai o metodo ReceberMensagem
void loop(){
  if(started == true){
    ReceberMensagem();
  }
}
// Aqui eu leio as mensagem e verifico o que recebi!
void ReceberMensagem(){
    int pos=0;
    pos=sms.IsSMSPresent(SMS_ALL);
    if(pos){
         sms.GetSMS(pos,n,smsbuffer,100);
           if(!strcmp(smsbuffer,"B")){
             Serial.println("Recebeu a mensagem B");
             EnviarMensagem();
            }      
          ExcluirMensagem();
       }  
}
  

//Aqui exclui a mensagem recebida!
void ExcluirMensagem(){
  
  for (int i=0; i<10; i++){
    int pos=sms.IsSMSPresent(SMS_ALL);
    if (pos!=0){ 
      if (sms.DeleteSMS(pos)==1){    
         Serial.println("Deletei mensagem!");      
      }else{
         Serial.println("Nao foi possivel deletar a mensagem!");         
      }
    }
  }
}

//Aqui vai enviar a mensagem para o celular!
void EnviarMensagem(){
  delay(500); 
  SerialGprs.println("AT+CMGF=1");
  delay(500);
  SerialGprs.print("AT+CMGS=");
  SerialGprs.write(byte(34));
  SerialGprs.print("99172841"); 
  SerialGprs.write(byte(34));
  SerialGprs.println(); 
  delay(500);  
  SerialGprs.print("Eu estou respondendo a mensagem! ");  
  SerialGprs.write(byte(26));
  delay(5000); 
  Serial.println("Enviado....");
}
//Aqui é o metodo do gps onde ele irá pegar as coordenadas para poder enviar de volta para o celular
void Gps(){
  
}

Me parece que o problema do gps é o conflito da biblioteca gsm do modulo, com o gps por que quando o se comunica com o serial do modulo parece que ele interrompe o serial do gps é maluco isso né mano???

Eu estou com o mesmo problema de você! veja o forum que abri

http://forum.arduino.cc/index.php?topic=300546.new#new

GSM +GPS on software Serial always seem a big problem due to the nature of the software seria; library.

My solution I have various vehicle location systems buil;t, you call the car and it responds with Lat and Long .. was to use the hadware UARTS on a Mega..

With harware looking after the two serial streams no problems at all.

Tem como pegar a latitude e a longitude do gps neo6m sem usar biblioteca??, caso eu consegui eu posto aqui

O nosso problema pode ser isso aqui veja :o

http://arduino.cc/en/Tutorial/TwoPortReceive

Eu acho que o problema é que a ide ou a biblioteca SoftwareSerial.h não está suportando comunicar duas serial ,por que fiz o método do endereço acima e não funcionou!