GPS with Arduino UNO - 2.

Hello again,

Since I gave up upon my EM 408 GPS, I've brought a EM 406A with a GPS shield cuz it's quite easier to deal with, and here's its datasheet: https://www.sparkfun.com/datasheets/GPS/EM-406A_User_Manual.PDF.
The problem now is that my GPS is blinking, but, there's no output on my serial screen, and I've tried those: https://www.sparkfun.com/tutorials/173 and EM-406A GPS From Scratch - Part 1. I've tried these codes and those ways of connecting the shield with the arduino with no use, so, any suggestions ?!!.

I've tried these codes and those ways of connecting the shield with the arduino with no use, so, any suggestions ?!!.

More random punctuation, maybe??;*$%?!!

I'm not hunting around guessing what code you are running. Post that code here.

PaulS:
More random punctuation, maybe??;*$%?!!

I'm not hunting around guessing what code you are running. Post that code here.

Thanks for being polite !!. Anyway, if you tried tiring your fingers and clicked on both links, you could've found them !.

Code 1:

/*
  6-12-12
  Aaron Weiss
  SparkFun Electronics, Beerware
  
  Example GPS Parser based off of arduiniana.org TinyGPS examples.
  
  Parses NMEA sentences from an EM406 running at 4800bps into readable 
  values for latitude, longitude, elevation, date, time, course, and 
  speed. Use 115200 baud for your serial port baud rate 
  
  For the SparkFun GPS Shield. Make sure the switch is set to DLINE.
  
  Once you get your longitude and latitude you can paste your 
  coordinates from the terminal window into Google Maps. Here is the 
  link for SparkFun's location.  
  http://maps.google.com/maps?q=40.06477,+-105.20997
  
  Uses the NewSoftSerial library for serial communication with your GPS, 
  so connect your GPS TX and RX pin to any digital pin on the Arduino, 
  just be sure to define which pins you are using on the Arduino to 
  communicate with the GPS module. 
  
  REVISIONS:
  1-17-11 
    changed values to RXPIN = 2 and TXPIN = to correspond with
    hardware v14+. Hardware v13 used RXPIN = 3 and TXPIN = 2.
  
*/ 

// In order for this sketch to work, you will need to download 
// TinyGPS and NewSoftSerial library from arduiniana.org and put them 
// into the libraries folder in your ardiuno directory.
#include <SoftwareSerial.h>
#include <TinyGPS.h>

// Define which pins you will use on the Arduino to communicate with your 
// GPS. In this case, the GPS module's TX pin will connect to the 
// Arduino's RXPIN which is pin 3.
#define RXPIN 2
#define TXPIN 3

// This is the serial rate for your terminal program. It must be this 
// fast because we need to print everything before a new sentence 
// comes in. If you slow it down, the messages might not be valid and 
// you will likely get checksum errors.
// Set this value equal to the baud rate of your terminal program
#define TERMBAUD  115200

// Set this value equal to the baud rate of your GPS
#define GPSBAUD  4800

// Create an instance of the TinyGPS object
TinyGPS gps;
// Initialize the NewSoftSerial library to the pins you defined above
SoftwareSerial uart_gps(RXPIN, TXPIN);

// This is where you declare prototypes for the functions that will be 
// using the TinyGPS library.
void getgps(TinyGPS &gps);

// In the setup function, you need to initialize two serial ports; the 
// standard hardware serial port (Serial()) to communicate with your 
// terminal program an another serial port (NewSoftSerial()) for your 
// GPS.
void setup()
{
 
  // Sets baud rate of your terminal program
  Serial.begin(TERMBAUD);
  // Sets baud rate of your GPS
  uart_gps.begin(GPSBAUD);
  
  Serial.println("");
  Serial.println("GPS Shield QuickStart Example Sketch v12");
  Serial.println("       ...waiting for lock...           ");
  Serial.println("");
}

// This is the main loop of the code. All it does is check for data on 
// the RX pin of the ardiuno, makes sure the data is valid NMEA sentences, 
// then jumps to the getgps() function.
void loop()
{
  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.
      }
  }
}

// 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);
  
  // Same goes for date and time
  int year;
  byte month, day, hour, minute, second, hundredths;
  gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);
  // Print data and time
  Serial.print("Date: "); Serial.print(month, DEC); Serial.print("/"); 
  Serial.print(day, DEC); Serial.print("/"); Serial.print(year);
  Serial.print("  Time: "); Serial.print(hour, DEC); Serial.print(":"); 
  Serial.print(minute, DEC); Serial.print(":"); Serial.print(second, DEC); 
  Serial.print("."); Serial.println(hundredths, DEC);
  //Since month, day, hour, minute, second, and hundr
  
  // Here you can print the altitude and course values directly since 
  // there is only one value for the function
  Serial.print("Altitude (meters): "); Serial.println(gps.f_altitude());  
  // Same goes for course
  Serial.print("Course (degrees): "); Serial.println(gps.f_course()); 
  // And same goes for speed
  Serial.print("Speed(kmph): "); Serial.println(gps.f_speed_kmph());
  //Serial.println();
  
  // Here you can print statistics on the sentences.
  unsigned long chars;
  unsigned short sentences, failed_checksum;
  gps.stats(&chars, &sentences, &failed_checksum);
  //Serial.print("Failed Checksums: ");Serial.print(failed_checksum);
  //Serial.println(); Serial.println();
  
  // Here you can print the number of satellites in view
  Serial.print("Satellites: ");
  Serial.println(gps.satellites());
}

Code 2:

void setup()
{
  Serial.begin(4800);
}


void loop()
{
  if (Serial.available()) Serial.write(Serial.read());
}

.

According to the link: GPS Shield Hookup Guide - SparkFun Learn, it says: "3 - Solder Jumpers: These jumpers, when disabled (solder removed), will disconnect the GPS communication lines (TX and RX) from the Arduino. This allows for the user to connect any digital line to the GPS communication lines. To use, simply disconnect the jumpers, then wire the TX and RX labeled pins on the shield to any one of the digital pins 2-13 on the shield.", so, do I have to remove the solder from it or not ??. If not, then how is my wiring going to be ?!!.

Well did you makes sure that the "UART Selection Switch" is set to UART?

If it's set to DLINE you won't see any output from the GPS (since it's set there to upload new code).

Of c ourse I assume the power switch is set on as well?

You really shouldn't have to mess with the solder jumpers unless you want to do something out of the ordinary.

Just a thought,

Brad
KF7FER

Thanks for your response, Brad. Do you mean that I have to set the switch to DLINE while uploading the code, and after uploading it, I set the switch to UART for the serial monitor ?!!.

Do you mean that I have to set the switch to DLINE while uploading the code, and after uploading it, I set the switch to UART for the serial monitor ?!!.

Yes?!!#$

I've attached a photo of how I physically connected the GPS shield with the arduino, and I've connected pin 2 to pin 3. I've used this code to run the GPS:

#include <SoftwareSerial.h>

SoftwareSerial gps(2,3); // RX, TX  Connect GPS TX to pin 3
void setup()
{
  Serial.begin(115200); // be sure to check lower right corner info in an open 'serial windows'
  gps.begin(4800);  // may be 4800, 19200,38400 or 57600

}

void loop()
{
  if (gps.available())  Serial.write(gps.read());
}

And, as I've done what Brad suggested me about the switch, this time I've got results, but in the form attached in the photo below !. Now, how can I fix this ?!!. Btw, I've set the serial monitor's baud rate 115200 just as a note !.

P4060002.JPG

Your "Code 2" example won't work. How does your serial connection connect to both the GPS and the serial monitor ?

I don't think it can.

Using an Uno, you would need to use softwareSerial for one of the serial connections.

And, as I've done what Brad suggested me about the switch, this time I've got results, but in the form attached in the photo below !

That looks like a speed mismatch. check that both the GPS>Arduino and Arduino>PC speed is correct. If you are not 110% sure what speed the GPS chip is outputting, try some different speeds.

You can verify the speed for the Arduino>PC connection by adding a statement like

Serial.println("Hello world") ;

at the end of your setup( ) function. Seeing this on the screen, will enable you to be certain that the speed is matched between the Arduino and the PC.

michinyon:
That looks like a speed mismatch. check that both the GPS>Arduino and Arduino>PC speed is correct. If you are not 110% sure what speed the GPS chip is outputting, try some different speeds.

Thanks for your response, michinyon. For the GPS's speed, the datasheet says that it works on 4800 only, so, should I try changing the serial speed ?!!.

I've tried changing the GPS's speed to 9600 and 14400 and the serial's speed to 4800 and 57600 with no use, still those weird characters appearing, any other suggestions ?!!.

Did you try michinyon's suggestion about a message in setup to confirm that your serial port matches the IDE's terminal program baud rate?

wildbill:
Did you try michinyon's suggestion about a message in setup to confirm that your serial port matches the IDE's terminal program baud rate?

Yes, when it was 115200, I've tried it and it worked !.

But still, the GPS's readings had the same strange characters, so, I wanted to make sure about my connections, do I have to connect pins 2 and 3, and that's it ??. If so, what other suggestions can you provide me ?!!.

2 and 3 and there also needs to be a ground connection.

wildbill:
2 and 3 and there also needs to be a ground connection.

But, shield is connected on top of the arduino board, so, do you mean I have to separate them ?!!

MAGMAM:

wildbill:
2 and 3 and there also needs to be a ground connection.

But, shield is connected on top of the arduino board, so, do you mean I have to separate them ?!!

No, it looks like the shield already takes care of it. I have an EM406 and breakout board so I connected it up to an arduino and ran your sketch - works fine once I set the IDE's serial terminal to 115200.

What you have still looks like a baud rate mismatch to me.

wildbill:

MAGMAM:

wildbill:
2 and 3 and there also needs to be a ground connection.

But, shield is connected on top of the arduino board, so, do you mean I have to separate them ?!!

No, it looks like the shield already takes care of it. I have an EM406 and breakout board so I connected it up to an arduino and ran your sketch - works fine once I set the IDE's serial terminal to 115200.

What you have still looks like a baud rate mismatch to me.

Which baud rate should I change ??. In the GPS's datasheet, it says that the GPS baud rate works on 4800, so, do you mean that I have to change the Serial's baud rate or GPS's baud rate and throw the datasheet behind my back or both ?!!.

do I have to connect pins 2 and 3, and that's it ?

No, it isn't. You also need power and ground.