Wireless GPS Communication

Hi There!

I'm learning as I go along with this, so if anything is blatantly wrong I do apologise!

I have recently started a project in which I aim to send gps coordinates via two xbees, to display within the serial monitor in Arduino's IDE. I have run the TinyGPS to test that the adafruit board I'm using works fine, and tested the xbees to turn a light on and off. However, I've not had any luck in sending the coordinates across the two xbees.

At the moment, I am using the adafruit ultimate GPS shield with an xbee shield on an arduino UNO, sending (or not sending) a signal to a second arduino with an xbee shield, wired up to my PC. I'm guessing that it may be an issue that they're both vying for the same RX and TX pins - but I have no idea how to change that.

If it would be easier, I can attach the code i've been using so far?

Any help would be fantastic.

Thanks in advance!

Please read "How to use this forum" and follow the directions. Specifically you need to post code using code tags and post a simple pencil sketch (not Fritzing) showing exactly how you have wired the modules together, including power and ground connections.

The setup itself is literally just an arduino UNO, with an Adafruit GPS shield and XBee shield stacked on top. for the receiving Arduino, it's the same - just minus the GPS.

The code I'm using for the emitting Arduino is as follows:

#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>


SoftwareSerial mySerial(6, 7);
SoftwareSerial xbeeSerial(2, 3);

Adafruit_GPS GPS(&mySerial);

#define GPSECHO  false

boolean usingInterrupt = false;
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy

void setup()  
{

 Serial.begin(9600);
 xbeeSerial.begin(9600);
 Serial.println("Adafruit GPS library basic test!");


 GPS.begin(9600);


 GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
 GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 1 Hz update rate
 GPS.sendCommand(PGCMD_ANTENNA);
 useInterrupt(true);

 delay(1000);
 mySerial.println(PMTK_Q_RELEASE);
}


SIGNAL(TIMER0_COMPA_vect) {
 char c = GPS.read();

#ifdef UDR0
 if (GPSECHO)
   if (c) UDR0 = c;  

#endif
}

void useInterrupt(boolean v) {
 if (v) {

   OCR0A = 0xAF;
   TIMSK0 |= _BV(OCIE0A);
   usingInterrupt = true;
 } else {

   TIMSK0 &= ~_BV(OCIE0A);
   usingInterrupt = false;
 }
}

uint32_t timer = millis();
void loop()                     // run over and over again
{

 if (! usingInterrupt) {

   char c = GPS.read();

   if (GPSECHO)
     if (c) Serial.print(c);
 }


 if (GPS.newNMEAreceived()) {


   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
 }


 if (timer > millis())  timer = millis();


 if (millis() - timer > 2000) { 
   timer = millis(); // reset the timer

   Serial.print("\nTime: ");
   Serial.print(GPS.hour, DEC); Serial.print(':');
   Serial.print(GPS.minute, DEC); Serial.print(':');
   Serial.print(GPS.seconds, DEC); Serial.print('.');
   Serial.println(GPS.milliseconds);
   Serial.print("Date: ");
   Serial.print(GPS.day, DEC); Serial.print('/');
   Serial.print(GPS.month, DEC); Serial.print("/20");
   Serial.println(GPS.year, DEC);
   Serial.print("Fix: "); Serial.print((int)GPS.fix);
   Serial.print(" quality: "); Serial.println((int)GPS.fixquality); 
   if (GPS.fix) {
     Serial.print("Location: ");
     Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
     Serial.print(", "); 
     Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
     Serial.print("Location (in degrees, works with Google Maps): ");
     Serial.print(GPS.latitudeDegrees, 4);
     Serial.print(", "); 
     Serial.println(GPS.longitudeDegrees, 4);

     Serial.print("Speed (knots): "); Serial.println(GPS.speed);
     Serial.print("Angle: "); Serial.println(GPS.angle);
     Serial.print("Altitude: "); Serial.println(GPS.altitude);
     Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
   }
 }
}

And on the receiving end, it looks like this:

void setup() {

Serial.begin(9600);
delay(1000);
Serial.println("\r\n-------- Config device --------");
Serial.flush();                                                            // Clear serial buffer

// ------ Xbee module configuration -------------

command_mode();
reset();
read_parameter();
config_parameter();
read_parameter();

// ------ End Xbee module configuration ---------

Serial.println(" \r\n ------ Receiving data from GPS -------- ");
}

void loop() {

read_data();                                                         // Reads data sended throw Xbee and writes to the serial port

}

// XBEE control commands : These functions manage the commands to enter and out from configuration mode,reset and save data
//---------------------------------------------------------------------------------------------------------
void command_mode(){                                                        // Enter in configuration mode
while(Serial.available()==0){
delay(1000);
Serial.print("+++");
delay(1000);
}
read_data();
}

void exit_cn(){                                                             // Exit command mode
Serial.println("\r\nATCN");
read_data();
Serial.println("\r\n***** Exit command mode *****");
delay(1000);
}

void reset(){                                                              // Reset Xbee (If you have not use write_config this functions reset the device to his previous values)
Serial.println("\r\nATRE");
read_data();
Serial.println("\r\n***** Device reset *****");
delay(1000);
}

void write_config(){                                                     // Writes the configuration in the Xbee module
Serial.println("\r\nATWR");
read_data();
Serial.println("\r\n***** Writting configuration in Xbee module *****");
delay(1000);
}

//-------------------------------------------------------------------------------------------------------------

// XBEE visualization commands : These functions read and write data from or to xbee or serial buffer
//-------------------------------------------------------------------------------------------------------------
void read_data(){               // Reading data response from serial xbee
byte data;
while(Serial.available()==0){}
while(Serial.available()>0){
data=Serial.read();
delay(10);                  // Waiting to receive new data
write_data(data);
}
Serial.flush();             // Clear serial buffer
}

void write_data(byte data){     // Write data from xbee to serial
Serial.print(char(data));
}

void read_parameter(){        // Reading configuration parameter
Serial.println("\r\n-------- Reading device parameter --------");

Serial.println("\r\nATID");  // Network ID
read_data();

Serial.println("\r\nATCH");  // Channel ID
read_data();

Serial.println("\r\nATMY");  // Address of the module
read_data();

Serial.println("\r\nATSH");  // Serial number of XBee  high (32 bits)
read_data();

Serial.println("\r\nATSL"); // Serial number of XBee low (32 bits)
read_data();

Serial.println("\r\nATDH"); // Destination address high (32 bits)
read_data();

Serial.println("\r\nATDL"); // Destination address low (32 bits)
read_data();

Serial.println("\r\nATBD"); // Baud rate
read_data();
}

void config_parameter(){        // Reading configuration parameter
Serial.println("\r\n-------- Config device parameter --------");

Serial.println("\r\nATID3329"); // Network ID
read_data();

Serial.println("\r\nATCHD");    // Channel ID
read_data();

//Serial.println("\r\nATDH");    // Destination address high (32 bits)
//read_data();

//Serial.println("\r\nATDL");    // Destination address low (32 bits)
//read_data();

}

This is all information I've found online, so if it's just not going to work, let me know and I'll start over!

You forgot the wiring diagram. We can't be bothered to look up what assumptions are made in the pin usage of the various shields -- and a conflict in that usage may be the problem.