Neo M8N GPS can't show lat and lon

-dev:
Try the NMEAGSV.ino example. The comments at the top describe how you need to enable the GSV sentence in NMEAGPS_cfg.h, and make sure your M8 is sending them. It sends them by default, but you can check with NMEAorder.ino. You may need to set LAST_SENTENCE to GGA.

The GSV sentences will set the gps.sat_count variable. Only read that variable after you read a new fix.

gps.sat_count tells how many satellites are "visible", and fix.satellites tells how many are locked (tracked).

The NMEAGSV.ino example shows how to access the satellite IDs, azimuth, elevation and signal strength (SNR). They are all stored in the gps.satellites array.

Here is a way to display a table form of the satellites array:

void loop()

{
  while (gps.available( gpsPort )) {
    fix = gps.read();

TableSatellitesInView();
  }

} // loop

//-----------------

#define CF(x) ((const __FlashStringHelper *) x) // a helper macro for the headers

static const char  NB_HEADER[] PROGMEM  = "nb ";
static const int8_t NBCOL_WIDTH          = sizeof(NB_HEADER)-1;

static const char  SAT_HEADER[] PROGMEM = " id el  az tr ";
static const int8_t SAT_COL_WIDTH        = sizeof(SAT_HEADER)-1;

static const int8_t NBCOL = 7;

void TableSatellitesInView()
{
  int i = 0;

if (fix.valid.time && fix.valid.date) {
    Serial.print( F("time and date are : ") );
    Serial << fix.dateTime; // this "streaming" operator outputs date and time
    Serial.println();
  }

Serial.print( CF(NB_HEADER) );
  Serial.print( '|' );
  for ( i=0; i < NBCOL; i++) {
    Serial.print( CF(SAT_HEADER) );
    Serial.print( '|' );
  }
  Serial.println();

repeat( '-', NBCOL_WIDTH );
  Serial.print( '|' );
  for ( i=0; i < NBCOL; i++) {
    repeat( '-', SAT_COL_WIDTH );
    Serial.print( '|' );
  }
  Serial.println();

print( gps.sat_count, NBCOL_WIDTH-1 );
  Serial.print( F(" |") );

for ( i=0; i < gps.sat_count; i++) {
    print( gps.satellites[i].id      , 3 );
    print( gps.satellites[i].elevation, 3 );
    print( gps.satellites[i].azimuth  , 4 );
    if (gps.satellites[i].tracked)
      print( gps.satellites[i].snr, 3 );
    else
      Serial.print( F(" - ") );
    Serial.print( F(" |") );

if ((i % NBCOL) == (NBCOL-1)) {
      Serial.println();
      repeat( ' ', NBCOL_WIDTH );
      Serial.print( '|' );
    }
  }

i = (i % NBCOL);
  while (i++ < NBCOL) {
    repeat( ' ', SAT_COL_WIDTH );
    Serial.print( '|' );
  }
  Serial.println();

repeat( '=', (NBCOL_WIDTH+1) + NBCOL * (SAT_COL_WIDTH+1) );
  Serial.println();

} // TableSatellitesInView

//-----------------
//  Print utilities

static void repeat( char c, int8_t len )
{
  for (int8_t i=0; i<len; i++)
    Serial.write( c );
}

static void print( int32_t val, int8_t len )
{
  char s[16];
  ltoa( val, s, 10 );
  repeat( ' ', len - strlen(s) );
  Serial.print( s );
}



This is a snippet from a long discussion in [this thread](https://forum.arduino.cc/index.php?topic=487187.0).

Thank you is work to me. for date and time, can I use date and timestamp format ? I use it
fix.dateTime
that code output timestamp, how to change timestamp GMT +7 with update date and time now ?

how to change timestamp GMT +7 with update date and time now ?

See NMEAtimezone.ino

-dev:
See NMEAtimezone.ino

I know adjustTime, but I need output to timestamp too

fix.dateTime is the timestamp. Pass it to adjustTime to offset it from GMT to your time zone (-7 in the code).

To print it, use

   Serial << fix.dateTime;

To write to an SD file, use

    logfile << fix.dateTime;

-dev:
fix.dateTime is the timestamp. Pass it to adjustTime to offset it from GMT to your time zone (-7 in the code).

To print it, use

   Serial << fix.dateTime;

To write to an SD file, use

    logfile << fix.dateTime;

how to use "heading" or "bearing" parameter ?

this my date and time fix, how to convert to timestamp ?

That is a time stamp. What format do you want?

beryindo:
how to use "heading" or "bearing" parameter ?

See the Data Model page.

"Heading" is the direction the GPS device is travelling.

"Bearing" is the direction to something else, like a target destination. "Bearing" can be measured from the direction of travel (from "Heading") or some absolute orientation (True North).

GPS can only give you heading when it is moving, not when it is stationary. Be sure to check fix.valid.heading to know if the GPS device has provided a heading value. BTW, the GPS heading is not very good when the speed < 5kph.

If you have a target location (i.e., a destination), you can calculate the bearing from your current location to the target, with respect to True North.

If you also have a magnetic compass device, you could determine the orientation of the Arduino system (the "platform"). This would tell you which direction the platform is "heading" even when it is not moving. Be aware that metal in the platform will affect the compass. If the Arduino is in or near a lot of metal (a car body or a motorcycle frame), it may not work.

KeithRB:
That is a time stamp. What format do you want?

timestamp format

-dev:
See the Data Model page.

"Heading" is the direction the GPS device is travelling.

"Bearing" is the direction to something else, like a target destination. "Bearing" can be measured from the direction of travel (from "Heading") or some absolute orientation (True North).

GPS can only give you heading when it is moving, not when it is stationary. Be sure to check fix.valid.heading to know if the GPS device has provided a heading value. BTW, the GPS heading is not very good when the speed < 5kph.

If you have a target location (i.e., a destination), you can calculate the bearing from your current location to the target, with respect to True North.

If you also have a magnetic compass device, you could determine the orientation of the Arduino system (the "platform"). This would tell you which direction the platform is "heading" even when it is not moving. Be aware that metal in the platform will affect the compass. If the Arduino is in or near a lot of metal (a car body or a motorcycle frame), it may not work.

I thnk ublox M8N includ with compass, how use it ?

So, what is it?
The number of fortnights since 4004 BC?

You will need to figure out the epoch. If you are lucky, the standard time functions can do it for you if they have the same epoch - that is not a requirement of the standard. Otherwise, build your own.

I thnk ublox M8N include with compass, how use it ?

Nope.

1505917185 is the number of seconds since the UNIX epoch, "1/1/1970 00:00:00" to "9/20/2017 21:19:45". Try this date/time calculator.

NeoGPS' time calculations use that epoch, by default. To get that seconds count from a GPS fix, just do this:

    NeoGPS::clock_t timestamp = fix.dateTime;

That is an unsigned long integer value that you can print to Serial or a logfile.

The NMEAtimezone.ino example shows many other date/time calculations, including timezone offsets (to get "local" time) and Daylight Saving Time (if your country observes it).

how to get coordinat format N and E ?

how to get coordinat format N and E ?

From the Data Model page:

...this fix variable (or any other variable of type gps_fix) contains the following members:

● fix.status, a status code

○ enum values STATUS_NONE, STATUS_EST, STATUS_TIME_ONLY, STATUS_STD or STATUS_DGPS

● a location structure (i.e., latitude and longitude), accessed with

○ fix.latitudeL() and fix.longitudeL() for the higher-precision integer degrees,
scaled by 10,000,000 (10 significant digits)

○ fix.latitude() and fix.longitude() for the lower-precision floating-point degrees (~7 significant digits)

:black_small_square: NOTE: these lat/lon values are positive for North or East degrees and negative for South or West degrees.
If the latitude is positive, print an 'N'. If it is negative, print an 'S'.

If the longitude is positive, print an 'E'. If it is negative, print a 'W'.

Always print the absolute value of the degrees.

The printLoc function in NMEAloc.ino might be a good place to start. It tests for negative and negates the degrees for printing.

this use what format ?

N, Lat:4725.9624, E, Lon:01912.5483

A weird one that is not the ISO 6709 Standard (Annex H - Text string representation) nor even a Proprietary NMEA sentence

Are you sure you are extracting the info correctly and fully?

I try equate output GPS with this format https://raw.githubusercontent.com/tananaev/traccar/master/tools/test-integration.py

'gps103' : 'imei:123456789012345,help me,1201011201,,F,120100.000,A,6000.0000,N,13000.0000,E,0.00,;',

can you help me ?

'gps103' : 'imei:123456789012345,help me,1201011201,,F,120100.000,A,6000.0000,N,13000.0000,E,0.00,;',

This looks like the Coban TK102 protocol

imei:123456789012345 => your IMEI
help me ==> This is position message
1201011201 ==> UTC Date and Time : YYMMDDHHMM
empty ==> don't know seems always empty
F ==> F for Fix (GPS locked and has position) or L for Lost (GPS is unlocked)
120100.000 ==> Time : HHMMSS.mmm Probably time in current time-zone or UTC if unset
A ==> could be to indicate that Altitude information is added at the end of the message
6000.0000,N ==> Latitude
13000.0000,E ==> Longitude
0.00 ==> speed nautic miles per hours
empty ==> possibly altitude

6000.0000,N,13000.0000,E

This is the original NMEA format for lat/lon. NeoGPS has a utility function that can output this format:

* Enable Degrees/Minutes/Seconds parsing in GPSfix_cfg.h:

    #define GPS_FIX_LOCATION_DMS

* Enable this option, required by DMS parsing, in NMEAGPS_cfg.h:

    #define NMEAGPS_PARSING_SCRATCHPAD

* Print the fix DMS fields from your sketch:

    fix.latitudeDMS.printDDDMMmmmm( GSM_PORT ); // or Serial for debugging
    GSM_PORT.print( ',' );
    GSM_PORT.print( fix.latitudeDMS.NS() ); // the 'N' or 'S' character

    GSM_PORT.print( ',' );

    fix.longitudeDMS.printDDDMMmmmm( GSM_PORT ); // or Serial for debugging
    GSM_PORT.print( ',' );
    GSM_PORT.print( fix.longitudeDMS.EW() ); // the 'E' or 'W' character

If you don't use fix.latitude() or fix.latitudeL() anywhere in your sketch, you could disable the normal location parsing:

    //#define GPS_FIX_LOCATION

This would save a little RAM, program space and parsing time, but you don't have to disable it.

Cheers,
/dev

-dev why i failed to combine gps tcp and sms

#include <GPSport.h>
#include <SoftwareSerial.h>
#include <NMEAGPS.h>
#define GSM_PORT softSerial
#define ON LOW
#define OFF HIGH
SoftwareSerial softSerial(6, 7); // RX, TX
NMEAGPS  gps; // Parshing Karakter dari GPS
gps_fix  fix; // Menampilkan data jika GPS Lock
#define gpsPort Serial

String bacaSMS = "";
String msg = "";
bool siap = 0;

unsigned int errorCounter;

const int Relay1 = 8;
const int Relay2 = 9;
const int Relay3 = 10;
const int Relay4 = 11;

int StatRelay1;
int StatRelay2;
int StatRelay3;
int StatRelay4;

void setup() {
  pinMode (Relay1 , OUTPUT);
  digitalWrite (Relay1, HIGH);
  pinMode (Relay2 , OUTPUT);
  digitalWrite (Relay2, HIGH);
  pinMode (Relay3 , OUTPUT);
  digitalWrite (Relay3, HIGH);
  pinMode (Relay4 , OUTPUT);
  digitalWrite (Relay4, HIGH);
  StatRelay1 = OFF;
  StatRelay2 = OFF;
  StatRelay3 = OFF;
  StatRelay4 = OFF;

  DEBUG_PORT.begin(9600);
  GSM_PORT.begin(9600);
  gpsPort.begin(9600);

  delay(30000);
  GSM_PORT.println("AT+CMGF=1");
  delay(1000);
  GSM_PORT.println("AT+CNMI=2,2,0,0,0");
  delay(1000);
  GSM_PORT.println("AT+CIPMUX=0");
  delay(1000);
  GSM_PORT.println("AT+CGATT=1");
  delay(1000);
  GSM_PORT.println("AT+CSTT=\"internet\",\"\",\"\"");
  delay(1000);
  GSM_PORT.println("AT+CIICR");
  delay(2000);
  GSM_PORT.println("AT+CIFSR");
  delay(1000);
  GSM_PORT.println("AT+CIPSTART=\"TCP\",\"domainku.com\",5109");
  delay(2000);
}

// uint8_t fixCount = 0;
void loop() {
  digitalWrite(Relay1, StatRelay1);
  digitalWrite(Relay2, StatRelay2);
  digitalWrite(Relay3, StatRelay3);
  digitalWrite(Relay4, StatRelay4);

  // GPS UBLOX M8N
  if (gps.available(gpsPort)) {
    fix = gps.read();
    //    fixCount++;
    //    if (fixCount >= 5) { // interval kirim data ke server 5 detik
    //      fixCount = 0;
    if (fix.valid.location) {
      GSM_PORT.println("AT+CIPSEND");
      GSM_PORT.print("FOLLOWIT,123456789012345,");
      char tanggalDanJam[12];
      sprintf(tanggalDanJam, "%02d%02d%02d%02d%02d", fix.dateTime.month, fix.dateTime.date, fix.dateTime.hours, fix.dateTime.minutes, fix.dateTime.seconds);
      GSM_PORT.print(fix.dateTime.year);
      GSM_PORT.print(tanggalDanJam);
      GSM_PORT.print(",");
      GSM_PORT.print(fix.latitude(), 6);
      GSM_PORT.print(",");
      GSM_PORT.print(fix.longitude(), 6);
      GSM_PORT.print(",");
      int i;
      float kecepatan;
      kecepatan = fix.speed_kph();
      i = (int) kecepatan;
      GSM_PORT.print(i);
      GSM_PORT.print(",");
      GSM_PORT.print("0");
      GSM_PORT.print(",");
      GSM_PORT.print(fix.satellites);
      GSM_PORT.print(",");
      int j;
      float altit;
      altit = fix.altitude();
      j = (int) altit;
      GSM_PORT.print(j);
      GSM_PORT.print(",F,");
      delay(1000);
      GSM_PORT.write(0x1A);
      delay(1000);
    }
  }
  // AKHIR GPS UBLOX M8N

  // SMS RELAY
  if (GSM_PORT.available()) {
    bacaSMS += (char)GSM_PORT.read();
    if (bacaSMS.indexOf("hidup") >= 0) {
      StatRelay1 = ON;
      digitalWrite(Relay1, StatRelay1);
      delay(7000);
      StatRelay2 = ON;
      digitalWrite(Relay2, StatRelay2);
      delay(500);
      StatRelay3 = ON;
      digitalWrite(Relay3, StatRelay3);
      delay(3000);
      StatRelay2 = OFF;
      StatRelay3 = OFF;
      siap = 1;
      errorCounter = 0;
      bacaSMS.remove(0);
    }
    else if (bacaSMS.indexOf("mati") >= 0) {
      StatRelay1 = OFF;
      siap = 0;
      errorCounter = 0;
      bacaSMS.remove(0);
    }
    else if (bacaSMS.indexOf("posisi") >= 0) {
      GSM_PORT.println("AT+CMGS=\"+628123456789\"");
      delay(1000);
      // latitude S hilangkan -, longtitud E
      GSM_PORT.print("http://maps.google.com/maps?q=");
      String latS = String(fix.latitude(), 6);
      latS.replace("-", "S");
      GSM_PORT.print(latS);
      GSM_PORT.print(",E");
      GSM_PORT.println(fix.longitude(), 6);
      delay(1000);
      GSM_PORT.write(0x1A);
      siap = 0;
      errorCounter = 0;
      bacaSMS.remove(0);
    }
  }
  // AKHIR SMS RELAY
}