Pages: [1]   Go Down
Author Topic: Ublox GPS NMEA output ?  (Read 2158 times)
0 Members and 1 Guest are viewing this topic.
Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I bought a GPS module LEA-4P-T-SMRT  half way down the page at http://www.rfdesign.co.za/pages/5645456/Brands/u-blox.asp

Its a "reference board" and has the older LEA-4P module on, and a 3.3v regulator.   ( The data in pin is 5 volt tolerant )

I have been trying it out with the  TinyGPS library that has always worked fine for me with my previous modules ( that have just doubled in price - hence this cheaper one )  this LEA-4 module is an old one now, they are up to 7 already.

Its putting out data OK, and with the following sketch :-
Code:
/*
  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.
*/

// In order for this sketch to work, you will need to download
// NewSoftSerial and TinyGPS libraries from arduiniana.org and put them
// into the hardware->libraries folder in your ardiuno directory.
// Here are the lines of code that point to those libraries.
#include <NewSoftSerial.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 10
#define TXPIN 9
//Set this value equal to the baud rate of your GPS
#define GPSBAUD 9600

// Create an instance of the TinyGPS object
TinyGPS gps;
// Initialize the NewSoftSerial library to the pins you defined above
NewSoftSerial 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(115200);
  //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...
 
    Serial.print(c, BYTE);
      if(gps.encode(c))      // if there is a new valid sentence...
      {
     Serial.println(" gps.encode(c)");    
        
        getgps(gps);         // then grab the data.
      }
  }
}

// The getgps function will get and print the values we want.
void getgps(TinyGPS &gps)
{
  
   Serial.println(" getgps routine");
  // 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();
}


I get :-

Code:
GPS Shield QuickStart Example Sketch v12
       ...waiting for lock...          


$GPZDA,083822.00,16,11,2012,00,00*63
$GPRMC,083823.00,V,,,,,,,161112,,,N*7B
$GPVTG,,,,,,,,,N*30
$GPGGA,083823.00,,,,,0,00,99.99,,,,,,*64
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGSV3,,1241,34,1,6,37352,0,01,2,530,2*A
$PGV,,211254,03,1,3,13,0,0321,1,5,24,72
GPSV3,,1,9,2,35,1,130,,10323,4F
$PGL,,,0883.0,,*4
GPDA0383.01611202,0006
$GPRMC,083824.00,V,,,,,,,161112,,,N*7C
$GPVTG,,,,,,,,,N*30
$GPGGA,083824.00,,,,,0,00,99.99,,,,,,*63
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGSV,,,1,41414,1,4,07,5,10301,2,8,033*A
$GGS,32,1,54305,,23710,,1,3,1,145824,*2
$PSV3,,1,0,1,35,3,3,08,1,3,3,*F
$GGL,,,0882.0,,N4F
GPDA0882.0,611202,00065
$GPRMC,083825.00,V,,,,,,,161112,,,N*7D
$GPVTG,,,,,,,,,N*30
$GPGGA,083825.00,,,,,

I put a couple of comments in to check,  one after the
 if(gps.encode(c))      // if there is a new valid sentence...

and it doesnt get printed ( nor the one to check if the getgps function runs }

Could it be that the format of the NMEA code is different , and the TinyGPS parsing doesnt recognise it ?

I was hoping that it would just churn out the right data as default,  I now see the datasheet says that it interleaves NMEA and UBLX messages

Any one tried these modules ?

I only want hours and minutes, so perhaps I can parse the time from say    $GPRMC,083823.00,  but its new ground for me ?

Perhaps I could test for the the $,  then put the next 10 characters in an array, and if the first 6 == GPRMC,  then I can take the next 4 characters, convert to integers, and use as the hour and minutes digits ?
     
« Last Edit: November 16, 2012, 07:27:46 am by Boffin1 » Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OK It wasnt as hard as I thought !

I have parsed the right numbers, just got to sort out the time difference and data types for my display and I am there.

I will post the result in case someone else runs into the same trouble with these units ( I see why they are going cheap )

If you want seconds too, you can make the buffer 12.

Code:
//Boffin1 GPS sentance parsing for odd output modules
// Just looks for $ and then saves the next 10 characters and matches GPRMC,
#include <NewSoftSerial.h>
#define RXPIN 10
#define TXPIN 9
#define GPSBAUD 9600
int buffer [10];
NewSoftSerial uart_gps(RXPIN, TXPIN);

void setup()
{
  Serial.begin(115200);
  uart_gps.begin(GPSBAUD);  
}

void loop()  {
  while(uart_gps.available())  {     // While there is data on the RX pin...          
      char inChar = uart_gps.read();  // read the first byte
   if ( inChar == 0x24 ) {                 // if it is $
      Serial.print(inChar);
      Serial.println("found $ ");
   for( int x=0; x<=9 ; x++ ){          // save the next 10 bytes to array buffer
        char inChar = uart_gps.read();
        buffer [x] = inChar;  
delay ( 2 ); // needs this or mins are -49 !

      }

   if ( buffer [0] == 71 && buffer [1] == 80 && buffer [2] == 82  && buffer [3] == 77 && buffer [4] == 67
        && buffer [5] == 44) {                //  if next 10 bytes = GPRMC,
     {           Serial.println(" got G P R M C , ")   ;
          int  rxhourten = buffer [6] - 48;           convert ascii to int
          Serial.print("rxhourten   = ") ;
          Serial.println(rxhourten) ;
          int  rxhourunit = buffer [7] - 48;
          Serial.print("rxhourunit   = ") ;
          Serial.println(rxhourunit) ;  
          int  rxminten = buffer [8] - 48;
          Serial.print("rxminten   = ") ;
          Serial.println(rxminten) ;
          int  rxminunit = buffer [9] - 48;
          Serial.print("rxminunit   = ") ;
          Serial.println(rxminunit) ;    
        }  
      }
    }
  }// end of while available
}// end of loop




« Last Edit: November 16, 2012, 02:16:24 pm by Boffin1 » Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Indonesia
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Hello world!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Boffin1,

I hope you could help me with my DFRduino GPS Shield for Arduino from DFRobot
Yeah, it's using lea blox chip
From the code here ==> http://www.dfrobot.com/wiki/index.php?title=DFRduino_GPS_Shield-LEA-5H_%28SKU:TEL0044%29

It's just showing up &GPGGA data that has been selected before for just showing some of data from GPGGA sentence
Is it possible to show up all of NMEA sentence using DFRduino GPS Shield??
I would really appreciate some helps,
Thanks  smiley-lol
Logged

Pages: [1]   Go Up
Jump to: