Go Down

Topic: NeoGPS and Local Time (Read 246 times) previous topic - next topic

abhi_nath

Hello all Veterans,

I am building a GPS logger for my vehicle and currently using NeoGPS library to parse GPS data. I'm from India and the existing code can show me the time based on my local timezone (using the method mentioned in the example)

This simple project has two outputs - One goes to a Nexiton display module and the other goes to SD card. Is there any way to send the full 'YYYY-MM-DD HH:MM:SS' time value to SD card and only 'HH:MM' to display unit?

I have used << operator to send the value to Serial as described by the author, but don't understand how to use it differently.

Any help from anyone would be appreciated.

PaulS

Quote
Is there any way to send the full 'YYYY-MM-DD HH:MM:SS' time value to SD card and only 'HH:MM' to display unit?
Yes.

Quote
I have used << operator to send the value to Serial as described by the author, but don't understand how to use it differently.
The author of what?

Post your code!
The art of getting good answers lies in asking good questions.

abhi_nath

I have attached the code I am using as of now.

Here's what is printing the time :

if (fix.valid.time && fix.valid.date) {
        adjustTime( fix.dateTime );
        print(             fix.dateTime         , validDT             , 20            );
      }


And here's the function :

static void print( const NeoGPS::time_t & dt, bool valid, int8_t len )
{
  if (!valid) {
    printInvalid( len );
  } else {
    DEBUG_PORT.write( ' ' );
    Serial << dt; // this "streaming" operator outputs date and time
    mySerial.print("Nex_DateTime.txt=") ;
    mySerial.print("\"") ;
    mySerial << dt  ;
    mySerial.print("\"") ;
    mySerial.write(0xff); //We need to write the 3 ending bits to the Nextion as well
    mySerial.write(0xff); //it will tell the Nextion that this is the end of what we want to send.
    mySerial.write(0xff);

    if (currentMillis - previousMillis > mydelay)
    {
      if (myFile)
      {
        myFile << dt ;
        myFile.print(", ") ;
      }
    }
  }
}


So you'll see every second the updated time(according to my timezone defined +5.5 hrs) is being sent to Nexiton display. Every 7 seconds it goes to SD logger.

I read the documentation for NeoGPS library and the definition is defined in NeoTime.cpp on how the << operator works

As I mentioned earlier, my requirement is to push the full date and time to SD logger but only HH:MM to display. 

PaulS

The NeoTime class overloads the << operator, which is why you are able to use the << operator to print the date and time. The class also offers seconds, minutes, hours, date, month, and year members, if you want to print the time or date differently.

Code: [Select]
char timeStg[10];
sprintf(timeStg, "%02d:%02d", dt.hours, dt.minutes);
mySerial.print(timeStg);
The art of getting good answers lies in asking good questions.

abhi_nath

Thanks Paul. That is exactly what I wanted. Now HH:MM is being displayed and the entire time value is getting saved in SD logger.

Really appreciate your help.

Now the first part of this project is complete. It displays Car inside temperature, GPS speed and GPS altitude, GPS Time(Hr:Mn) and stores Number of satellites, LAT, LONG along with other information in SD card.

My next step would be to add a sim900/800 module and periodically (say every minute) send the data to thingspeak or any other website so that it can be tracked as well. Lets see how quickly I can come up with a solution for that.

As the GPS altitude is not very accurate, I might make use of a BMe280 in future.

Only concern as of now is the question if a Pro Mini can fit the entire code.

Thanks a ton.

Go Up