AssetTrackerRK Help

Hello, I have a Particle BSoM (B404V1.0.0) and a UBlox SAM-M8Q GPS receiver that use the I2C bus to communicate. My issue is that it takes way too long to get a GPS fix, so I would like to use the AssetTrackerRK library to speed up the TTFF.

  1. Can I use this library with my hardware with minimal changes to the 11-assistnowtest example?
  2. In the Particle Web IDE, I attempted to compile the 11-assistnowtest.ino example and I am getting the following errors. The only changes i made were uncommenting line 44: t.withI2C();

11_assistnowtest.ino:18:1: error: ‘AssetTracker’ does not name a type
11_assistnowtest.ino: In function ‘void setup()’:
11_assistnowtest.ino:44:2: error: ‘t’ was not declared in this scope; did you mean ‘tm’?
11_assistnowtest.ino: In function ‘void displayInfo()’:
11_assistnowtest.ino:73:7: error: ‘t’ was not declared in this scope; did you mean ‘tm’?

Code pasted below:

#include “Particle.h”

#include “UbloxGPS.h”

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);

SerialLogHandler logHandler;

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

AssetTracker t; // Support for basic GPS functionality
Ublox ublox; // Adds in special features of the u-blox GPS models
UbloxAssistNow assistNow; // Adds in assist now for faster time-to-first-fix

void displayInfo();

unsigned long lastSerial = 0;
unsigned long lastPublish = 0;
unsigned long startFix = 0;
bool gettingFix = false;

void setup() {
// This is optional, it just provides time to connect the serial monitor to observe what it’s doing
// waitFor(Serial.isConnected, 10000);

// You must obtain a u-blox API token and paste it here
// https://www.u-blox.com/en/assistnow-service-registration-form
assistNow.withAssistNowKey("O-SL1iDHSzeBrNdhYRWo8w");

// To run without providing location data (not recommended) uncomment the following line:
// assistNow.withDisableLocation();

// You must call setup()
assistNow.setup();

// Use I2C mode when running the Feather test. Note that the AssetTracker V1/V2 uses serial, not I2C!
t.withI2C();

// Run in threaded mode - this eliminates the need to read Serial1 from loop or updateGPS() and dramatically
// lowers the risk of lost or corrupted GPS data caused by blocking loop for too long and overflowing the
// 64-byte serial buffer.
t.startThreadedMode();

// Turn on GPS module - required for AssetTracker V2
t.gpsOn();

// Set antenna (false = internal, true = external). Default is internal if not set.
// ublox.setAntenna(true);

Particle.connect();

}

void loop() {
// You must call these from your application loop!
ublox.loop();
assistNow.loop();

displayInfo();

}

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

	char buf[128];
	if (t.gpsFix()) {
		snprintf(buf, sizeof(buf), "location:%f,%f altitude:%f satellites:%d hdop:%d", t.readLatDeg(), t.readLonDeg(), t.getAltitude(), t.getSatellites(), t.getTinyGPSPlus()->getHDOP().value());
		if (gettingFix) {
			gettingFix = false;
			unsigned long elapsed = millis() - startFix;
			Log.info("%lu milliseconds to get GPS fix", elapsed);
		}
	}
	else {
		snprintf(buf, sizeof(buf), "no location satellites:%d", t.getSatellites());
		if (!gettingFix) {
			gettingFix = true;
			startFix = millis();
		}
	}
	Log.info(buf);

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

}

In order to use the AssetTracker class you need to include:

#include "AssetTrackerRK.h"

instead of

#include “UbloxGPS.h”

Awesome thank you it compiled fine after making that change!

So I am just consistently getting “no location satellites” I have been trying to get a signal for over ten minutes and its still not getting a fix… Any suggestions?

There should be a number after “no location satellites:” What is it?

If it’s zero, the GNSS can’t see any satellites. Check the antenna settings. You can also try setting it outside.

If it’s more than a couple but less than 8, then it’s because the sky view is obstructed. You won’t be able to test it in that location. It might work better in a window, but you may need to take it outside with a good view of the sky.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.