Go Down

Topic: My GPS never work!! (Read 700 times) previous topic - next topic

pierrot10

Mar 29, 2013, 08:08 am Last Edit: Mar 30, 2013, 07:14 pm by pierrot10 Reason: 1
Dear All, good morning!!

I am working hard to understand my gps antenna.
I do have an Arduino Uno which will be replace by an Arduino Mini Pro 5V
I also have a GPRS module connected to the arduino Uno.

On Pin 4 and 5 I connected a GPS antena. First, I tried with this one:
https://www.sparkfun.com/products/465
then I ordered and try this one
https://www.sparkfun.com/products/11571

Both are connected through this connector breakout
https://www.sparkfun.com/products/10402

On my Sketch I define pin4 as RX and pin5 as TX
SoftwareSerial uart_gps(4, 5);

I have now the RX wire of the breakout connected to the pin 5 and TX wire connected to pin 4.
I also try to invert it. RX wire of the breakout, connected to the 4, and TX wire tp pin5.

Finaly I am using a simple code to display position
Code: [Select]

/*
 6-8-10
 Aaron Weiss
 SparkFun Electronics
 
 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.
 
 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 library from arduiniana.org and put them
// into the hardware->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 4
#define TXPIN 5
//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()
{
 // 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.
 Serial.begin(4800);
 //Sets baud rate of your GPS
  uart_gps.begin(GPSBAUD);
 
 Serial.println(F(""));
 Serial.println(F("GPS Shield QuickStart Example Sketch v12"));
 Serial.println(F("       ...waiting for lock...           "));
 Serial.println(F(""));
}

// 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(Serial.available())
 while(uart_gps.available())     // While there is data on the RX pin...
 {
      // int c = Serial.read();
     byte 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)
{
 Serial.println("getGPS");
 // 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();
}




As well with the fist antena, than with the second, it very rarely works!

When it works:
Last week, I was in my sofa. I am leaving on 7th floor. I was seeting at 3m of the big window. The fix/positions were not displayed.
Then I put my module on the table whihc is a 0.2m from thew window, and the module start displaying fix. OK, I understand the the building can stop the signal. But it not beacuse it works once, that it always work. It's not working each time. Also a Cellular antena/provder is close to my building. may be it can make interference

When it does not work (While I am not at home)
What it frustred me, and when I am teaveling in the train. Right now I am maming 2hour train. Then I am moving. I am seeting close to the window. The Antenna is at 1cm of the window and it never display fix!!!!!

Once I will try to be in a midlle of a field, but my goal is to provide a tool which work any where.

Is there someone who can provide me some advice.

For exemple:
Is correct to connect the antena from RX to TX, or the wire should be connect RX to RX?
IS correct to define pin 4 and 5, instead of 0 and 1, or 2 and 3
Someone know the best and correct use of this antenna : https://www.sparkfun.com/products/11571

Many thnak for any advise you can provide and I hope I provided enougth information

Cheers
Il ne suffit pas de tout savoir, la persévérance, c'est déjà presque tout!

pierrot10

Any idea? It will help  :)
Cheers
Il ne suffit pas de tout savoir, la persévérance, c'est déjà presque tout!

el_supremo

There is conflicting info about what baud rate this unit uses: https://www.sparkfun.com/products/11571
but apparently it actually runs at 9600 baud - not 4800. So, try changing the baud rate to 9600. And if that fails, try what the datasheet says is the default 38400.

Pete

pierrot10

Dear Pete,

Thank for your answer.
But unfortunately it does not work.

I am working with a MacBook. The USB cable is conneted to the Arduino UNO.
I changed the GPS rate to 9600 then 38400, but it did not display the fix...  :smiley-fat:

Now I amsling my self if the power provided by my Mac USB is enought.
At the moment my Battery (1000mA) is down, but I will try later with it when it will be charged.
But in any case it has been working (sometime) with the MAC USB port.
Il ne suffit pas de tout savoir, la persévérance, c'est déjà presque tout!

pierrot10

#4
Apr 01, 2013, 12:26 am Last Edit: Apr 01, 2013, 12:33 am by pierrot10 Reason: 1
Do you know what does it means this:
Quote

TTL serial

and
Quote

Note: We are carrying the "T" option of this module which is TTL-UART and not USB.

https://www.sparkfun.com/products/11571

Should it be connected to port 0 and 1, instead of 4 and 5?

What is exactely the VBAT?

Thank for all
Il ne suffit pas de tout savoir, la persévérance, c'est déjà presque tout!

el_supremo

TTL means it uses zero and five volts to transmit the GPS data. You can connect it directly to pins 4 and 5 on your Arduino and it should work as long as you get the pins connected the right way round.
Your Mac laptop should have no trouble providing the power needed unless the battery was very low in which case the laptop probably wouldn't run properly anyway.
VBat is an input from an optional battery backup. If it is present, when you shut down the GPS, the VBat allows the GPS to maintain an internal memory which retains information about the GPS satellites that it has seen recently. When you turn the GPS back on this info allows it to lock onto the satellites faster than if it was being powered on from a "cold" start.

Pete

Go Up