AssetTrackerRK does not show the coordinates

Hello @ScruffR
I’m working on the AssetTrackerRK library, on an E-series electron board, and a SAM-M8Q, following the recommendations of using this library “AssetTrackerRK”, the LED indicator of the SAM-M8Q, indicates that it is already connected, but not I can see the coordinates, latitude and longitude, can you help me please?

#include <AssetTrackerRK.h>

#include "Particle.h"

#include "AssetTrackerRK.h" // only used for AssetTracker::antennaExternal

// Port of TinyGPS for the Particle AssetTracker
// https://github.com/mikalhart/TinyGPSPlus
#include "TinyGPS++.h"

SYSTEM_THREAD(ENABLED);

/*
   This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object directly.
 */

void displayInfo(); // forward declaration

const unsigned long PUBLISH_PERIOD = 120000;
const unsigned long SERIAL_PERIOD = 5000;
const unsigned long MAX_GPS_AGE_MS = 10000; // GPS location must be newer than this to be considered valid

// The TinyGPS++ object
TinyGPSPlus gps;
unsigned long lastSerial = 0;
unsigned long lastPublish = 0;
unsigned long startFix = 0;
bool gettingFix = false;

void setup()
{
	Serial.begin(9600);

	// The GPS module on the AssetTracker is connected to Serial1 and D6
	Serial1.begin(9600);

	// Settings D6 LOW powers up the GPS module
    pinMode(D6, OUTPUT);
    digitalWrite(D6, LOW);
    startFix = millis();
    gettingFix = true;

    // If using an external antenna, uncomment this block
    // { AssetTracker t; t.antennaExternal(); }
}

void loop()
{
	while (Serial1.available() > 0) {
		if (gps.encode(Serial1.read())) {
			displayInfo();
		}
	}

}

void displayInfo()
{
	if (millis() - lastSerial >= SERIAL_PERIOD) {
		lastSerial = millis();

		char buf[128];
		if (gps.location.isValid() && gps.location.age() < MAX_GPS_AGE_MS) {
			snprintf(buf, sizeof(buf), "%f,%f,%f", gps.location.lat(), gps.location.lng(), gps.altitude.meters());
			if (gettingFix) {
				gettingFix = false;
				unsigned long elapsed = millis() - startFix;
				Serial.printlnf("%lu milliseconds to get GPS fix", elapsed);
			}
		}
		else {
			strcpy(buf, "no location");
			if (!gettingFix) {
				gettingFix = true;
				startFix = millis();
			}
		}
		Serial.println(buf);

		if (Particle.connected()) {
			if (millis() - lastPublish >= PUBLISH_PERIOD) {
				lastPublish = millis();
				Particle.publish("gps", buf, PRIVATE);
			}
		}
	}

}

Thanks

Another point:
Is it possible to see in some way if serial port 1 is available?

Thanks

Try running the data dump example instead to see if the GPS is outputting any information.

https://build.particle.io/libs/AssetTrackerRK/0.2.3/tab/example/7_DataDump.cpp

Flash that code to your Electron, then monitor the USB serial debug port to see what is printed.

1 Like

Hello @rickkas7

thanks for the info.
I already tried to execute the data dump example to see if the GPS is emitting some information, and did not show any data

Any recommendation?

Thanks

  • I’ve never tested it with the u-blox SAM-M8Q. The AssetTracker and my board uses the MAX-M8Q, but it should work with the SAM-M8Q.

  • Makes sure your board is configured for serial. The AssetTrackerRK library can communicate with the u-blox by I2C (u-blox refers to this as DDC), but it requires a different configuration.

  • Make sure TX on the GPS is connected to RX on the Electron and vice versa.

  • The default on the GPS is 9600 8N1, so unless you’ve reset it on the GPS chip, it should be fine.

2 Likes

Thanks
very useful