GPS em-406a functionality

Hi guys,

I am using a GPS em-406a connected on an Arduino UNO and it does not receive any coordinates.

Please see below my code:

#include <XBee.h>

#include <TinyGPS.h>

#include <SoftwareSerial.h>

// Define SoftwareSerial TX/RX pins

#define xbeeRX 2

#define xbeeTX 3

#define gpsRX 4

#define gpsTX 5

//create xbee connection

SoftwareSerial xbeess = SoftwareSerial(xbeeRX, xbeeTX);

//create gps connection

SoftwareSerial gpsss = SoftwareSerial (gpsRX, gpsTX);

//Create an XBee object

XBee xbee = XBee();

TinyGPS gps;

//Define the Destination address of the packets

XBeeAddress64 destaddress = XBeeAddress64(0x0013A200, 0x406F1997);

char Hello = “Hello World\n\r”;

void setup()

{

Serial.begin(9600); //connect serial

xbeess.begin(9600); //connect xbee

gpsss.begin(4800); //connect gps

//We hook the XBee into the Software Serial

xbee.setSerial(xbeess);

Serial.println(“Goodnight moon!”);

}

void loop() // run over and over

{

/*long flat, flon;

gps.get_position(&flat, &flon);

char* lat;

sprintf(lat, “%f”, flat);

char* lon;

sprintf(lon, “%f”, flon);*/

Serial.println(“in the loop”);

while (gpsss.available()){

Serial.println(“fail”);

if (gps.encode(gpsss.read())){

Serial.println(“hello”);

//Serial.println(*lat + " " + *lon);

}

}

ZBTxRequest zbtx = ZBTxRequest(destaddress, (uint8_t *)Hello, strlen(Hello));

xbee.send(zbtx);

delay(1000);

}

I am also using an xbee module which is working fine. I have also commented out some of the code and left only the critical part of it.

Regarding the GPS, It does NOT enter the “while (gpsss.available())” loop. I have also tried “Serial.print(gpsss.read());” and it prints “-1”.

Although im a rookie on these stuff, I am sure that my connections are correct ----> pin 1&5 = GND, pin 2 = VIN, pin 3 = Rx, pin 4 = Tx

and I have connected them to respective pin on the arduino -----> GND = GND, VIN = 5V, Rx = pin 4, Tx = pin 5

Any ideas of how to resolve this problem would be most appreciated.

Thank you in advance,

gabys

It appears you need to flip TX/RX pins. The TX/RX labels are relative to each device, i.e. GPS transmits, Arduino receives.

Thank you JimEli! It worked like a charm!