Ultimate GPS DataLogger Shield - RTC and GPS.

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Skyler76
 
Posts: 19
Joined: Mon Jul 27, 2015 5:43 pm

Ultimate GPS DataLogger Shield - RTC and GPS.

Post by Skyler76 »

OK, so I am using this shield on a mega (will be using 15 of them in the near future). I am using TinyGPS for my interface with the GPS and it seems to work with one caveat. Resolution. I only get two decimal points on the lat and long which translates to really crappy resolution. Kind of makes me feel dumb as I am sure there is an obvious answer to this question but still, I cannot figure it out for the life of me.

The second question is with regards to the RTC. The datasheet says that the RTC is auto set when the GPS gets a fix (which it has got a few times). Given that I have a battery (new) in the coin cell slot I'd expect this to always give me a valid time however it always gives me a time as if there is no RTC installed (0 hour/ 0 min on reboot).


Thoughts? Thanks in advance. I am sure i am being dumb but cannot figure out either of these problems.

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by Franklin97355 »

Perhaps, if you post your code and a description or drawing of your connections between it all we can help. Please use the code button "</>" or

Code: Select all

 tags when posting code to the forums.

User avatar
Skyler76
 
Posts: 19
Joined: Mon Jul 27, 2015 5:43 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by Skyler76 »

Here you go. There is a bunch of commented stuff out. Currently just trying to get the RTC to work but uncommenting the lat/long write will give me two decimal places.

Connections are simple enough to describe.

Shield Rx -> Mega Tx1
Shield Tx -> Mega Rx1

Code: Select all

#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <TinyGPS.h>


TinyGPS GPS;
String SYS_NAME = "DT-01";
int SYS_SERIAL_LEN = 200;
int SYS_BAUD = 9600;
bool v_MenuMode = false;
String v_SerialString = "";
int v_SerialDWORD =0 ;
bool v_SerialReadComplete = false;
bool v_GPS_DataRec = false;
String v_NMEA = "";

void setup() {

   Serial.begin(SYS_BAUD);
   Serial1.begin(SYS_BAUD);
   v_SerialString.reserve(SYS_SERIAL_LEN);
   v_NMEA.reserve(100);
   
}

void loop() {
  

  //<-- Menu System  //
  
    if(v_GPS_DataRec){
      
      
     delay(1000);
float flat, flon;
 unsigned long fix_age;
// returns +/- latitude/longitude in degrees
GPS.f_get_position(&flat, &flon, &fix_age);
float falt = GPS.f_altitude(); // +/- altitude in meters
float fc = GPS.f_course(); // course in degrees
float fk = GPS.f_speed_knots(); // speed in knots
float fmph = GPS.f_speed_mph(); // speed in miles/hr
float fmps = GPS.f_speed_mps(); // speed in m/sec
float fkmph = GPS.f_speed_kmph(); // speed in km/hr
      
     /*Serial.println(fix_age);
      Serial.println(flat);
 
      Serial.println(flon);
      Serial.println(fmph);
     Serial.print(GPS.satellites(), DEC);*/
     Serial.print("Hour: ");
     Serial.println(hour());
    }
  

}
void serialEvent() {
  if(v_MenuMode){
    
   v_SerialDWORD = Serial.read();
   v_SerialReadComplete = true;
    Serial.println("Done with menu option");
    return; 
  }
  while (Serial.available()) {
    
    // get the new byte:
    char inChar = (char)Serial.read(); 
    // add it to the inputString:
    v_SerialString += inChar;
    //Serial.println(inChar);
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      v_SerialReadComplete = true;
      
    } 
  }
}
void serialEvent1(){
  
  while (Serial1.available()) {
    
    // get the new byte:
    int inChar = Serial1.read(); 
    GPS.encode(inChar);

   v_NMEA += inChar;
  
 
    if (inChar == '\n') {
      v_GPS_DataRec = true;
      
    } 
  }
}



User avatar
Skyler76
 
Posts: 19
Joined: Mon Jul 27, 2015 5:43 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by Skyler76 »

No dice on this?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by adafruit_support_mike »

I don't think the TinyGPS library does any truncation, but Serial.print() automatically truncates floating point numbers to two decimal places unless told otherwise: https://www.arduino.cc/en/Serial/Print

That shouldn't have any effect on your readings though.

WRT the battery, are you sure you have it the right way up? Coin cells are slightly odd compared to other batteries because the case is positive and the button on top is negative. You want the button against the PCB.

User avatar
Skyler76
 
Posts: 19
Joined: Mon Jul 27, 2015 5:43 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by Skyler76 »

That would be my problem on the decimal places! I knew it was something dumb!

Yes I am positive on the polarity of the battery (no pun intended..well maybe, a little). Any other thoughts on this?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by adafruit_support_mike »

Check the raw NMEA sentences to see what you're getting in those.

The parser may return null data for sentences that don't say they have a fix.

User avatar
Skyler76
 
Posts: 19
Joined: Mon Jul 27, 2015 5:43 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by Skyler76 »

The GPS data is fine now that I realize it's cutting the decimal places in Serial.print but the RTC is not setting automatically - or I am reading it wrong. I was assuming I just used hour(), minute() etc to get the time from the RTC, I have a feeling I may being completely dumb though.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by adafruit_support_mike »

Are you getting zeros in the raw NMEA sentences?

User avatar
Skyler76
 
Posts: 19
Joined: Mon Jul 27, 2015 5:43 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by Skyler76 »

These are some typical sentences that the device puts out.

$GPGGA,214952.000,3841.3314,N,12104.5618,W,1,05,2.22,204.3,M,-22.4,M,,*5B
$GPGGA,214951.800,3841.3313,N,12104.5617,W,1,05,2.22,204.2,M,-22.4,M,,*59
$GPRMC,214951.800,A,3841.3313,N,12104.5617,W,0.64,2.74,060815,,,A*78

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by adafruit_support_mike »

The field directly after the sentence name is the timestamp:

Code: Select all

$GPGGA,214952.000,3841.3314,N,12104.5618,W,1,05,2.22,204.3,M,-22.4,M,,*5B
       ^^^^^^^^^^

214952.000 == 9:49:52.000 PM, UTC
If you aren't getting a time from that, the problem is in the software rather than the hardware.

User avatar
Skyler76
 
Posts: 19
Joined: Mon Jul 27, 2015 5:43 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by Skyler76 »

Yes but in your documentation for the shield it says the RTC will automatically set itself when a fix is acquired. Maybe I am confused.

User avatar
Skyler76
 
Posts: 19
Joined: Mon Jul 27, 2015 5:43 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by Skyler76 »

"The real time clock will automatically set itself to the correct UTC time as soon as the GPS gets its
first correct signal from a satellite. Without the battery, if the GPS loses power, it will forget the time
and has to wait till it gets signal again to reset. But, if you have the battery in, it will keep time even
after a power loss. We recommend it highly!"

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Ultimate GPS DataLogger Shield - RTC and GPS.

Post by adafruit_support_mike »

The GPS sentences contain timestamps. That means the RTC is working.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”