Arduino + Ultimate GPS Shield + Xbee Shield + Xbee

Hello guys,

I wanna make a project using an Arduino UNO R3 + Ultimate GPS Shield (with built in gps) from Adafruit + Xbee Shield + Xbee S2 and another Arduino MEGA with just Xbee Shield + Xbee module

My problem is that i get "programmer out of sync" if i try to upload a sketch on the first Arduino with the two shields.

Is it the serial port pins? I dont know why. Please advice.

Remove the Xbee S2, you cannot upload with those attached to your Arduino.

that works but what is the reason?

Also my xbee is not recongnisable in XCTU with the following arduino code

is it because of the softwareSerial?(gps works though),any help?

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


SoftwareSerial mySerial(8, 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(115200);
 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);
   }
 }
}

Hi,

It’s because Arduino USB interface uses same hardware serial interrupts (d2 and d3) for both transfer program and reading/writing on xbee so it’s conflicting.

About your xbee not available : I have exactly the same problem !!! I’m stuck for more than a week… Tested on two sets of arduino/xbee shield/xbee (to see if it was an hardware problem or not) but the test xbeeserial.available is never true.

If you find some information/clue/solution, please write it here :wink:

You will find my questions here :

http://forum.arduino.cc/index.php?topic=296789.0 http://www.seeedstudio.com/forum/viewtopic.php?f=23&t=5772

hey man if you upload this code your xbee should be recongnisable

void setup() {
  // put your setup code here, to run once:

}

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

that means that something in the code cant work with that shield we have or something else. Really if you can find anything i would be grateful.

wow dude ! you saved my life !!!

So, here is what I've done : - I've uploaded empty program like you told me -> didn't work BUT : - I've changed my jumpers to use D0 and D1 (by reading on arduino card RX = 0 and TX = 1).

So, with this configuration, XCTU recognized the xbee module and let me see its settings. From what I've seen, I think you have to configure which pin to use to read and write data. I don't really know if i'm true but I will search about that now ;)

Thanks for your help

BTW, if I find something, i will post it here ;)

hey man glad it worked. Well i have indentified that whenever i use Serial.begin command my xbee wont get recognised.

any clues why is that?

I think it's about good use of RX TX and DX pins. So close to the solution...

I use Arduino Mega so I have 3 hardware serial, I will try that way because using SoftwareSerial doesn't work. What I would suggest you is trying to configure DIO through XCTU config (to set DI and DO High on your DN pins) and see if it helps

How can i configure the RX TX and DX pins using the XCTU?

Hi,

forget about what I said... I made it !!! So : First of all, restore default xbee settings through XCTU

For the emitter : you need to connect XBEE RX0 to the serial port TX of your arduino of your choice (notice the swap TX/RX) you need to connect XBEE TX1 to the serial port RX of your arduino of your choice (same thing about the swap)

For the receiver : You need to connect TX1 of xbee to TX of your choice You need to connect RX0 of xbee to RX of your choice

When I say TX or RX of your choice, I mean that in my case, with arduino mega, I have 3 hardware serial ports. So I use them. For a arduino uno, I think you have only one hardware serial port : So you will have to choose a free pin (DX) and map to softwareserial RX and TX port. Tell me if you made it work

PS : I've first tried to make an emitter by code and receiver with XCTU to see if it works.

man can you write me some sample code?

I have configured one xbee to be coordinator and one to be router both AT.

can you please write me some sample code that works to send a single message across?

i cant seem to make it work.

First, I think you should try to communicate with two xbee without the mode coordinator/router... The code is as simple as sending characters to Serial port

For the emitter : Create an instance of SoftwareSerial with your two ports (let's say you name it xbee) initialize baud rate to your xbee (9600) in the loop just make xbee.println("Hello") and a delay(1000)

Receptor : Same thing but using xbee.available and xbee.read

By my side, I have only one problem : what I receive is not really what I send with the other xbee. I think I have to adjust something. but they communicate.

To make it simplier for you : Try to cocde an emitter and test it with your second xbee connected to xctu (xctu will show you received data) Then, try to code a receiver and with your second xbee connected to XCTU, you can send data to it.

Hey man i think the jibberish letters you get are because you have the rx/tx pins the other way around or the baud rate is not set correctly either in arduino IDE or in XCTU...

i will try that. So far i've worked only one direction communication...