Can I send location information via USB serial Tracker One

I have been trying to find a way to slightly modify the v19 firmware for my tracker one. I would like send location information via USB serial, such as latitude/longitude and speed. I am unfamiliar with C++ and having difficulty logging this information. I would like to do so in a way that does not affect my current integrations.

Yes, this can be done, but more specifically:

Is this for debugging purposes, or to be machine read by something else? The reason is that by default logging debug messages are printed to USB serial.

Do you want to only log at the existing publish frequency based on the current cloud settings, or do you want to print the current location more frequently than that since local printing doesn't use data operations.

Do you only want to print GNSS information, or do you want to print to USB serial location based off location fusion, which includes cellular or Wi-Fi geolocation? This can't be done more frequently than cloud publish, and requires more data operations.

I would like to do this to be machine read. I am hoping to find a method that works to more frequently print location information without data operations, as well as work to communicate to a computer frequently in an out of cellular service. I only need to print GNSS information.

I didn't run this on a device, but it does compile and should be easy enough to fix or modify. There are only a handful of lines changed from the standard main.cpp in tracker-edge.


#include "Particle.h"
#include "tracker_config.h"
#include "tracker.h"

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);

#if TRACKER_PRODUCT_NEEDED
PRODUCT_ID(TRACKER_PRODUCT_ID);
#endif // TRACKER_PRODUCT_NEEDED
PRODUCT_VERSION(TRACKER_PRODUCT_VERSION);

STARTUP(
    Tracker::startup();
);

// Disable serial logging so the output is not mixed in with 
/*
SerialLogHandler logHandler(115200, LOG_LEVEL_TRACE, {
    { "app.gps.nmea", LOG_LEVEL_INFO },
    { "app.gps.ubx",  LOG_LEVEL_INFO },
    { "ncp.at", LOG_LEVEL_INFO },
    { "net.ppp.client", LOG_LEVEL_INFO },
});
*/

// How often to print the location to USB serial (15s = 15 second, 2min = 2 minutes, etc.).
const std::chrono::milliseconds printLocationPeriod = 15s;

unsigned long printLocationLast = 0;

void setup()
{
    Serial.begin();

    Tracker::instance().init();
}

void loop()
{
    Tracker::instance().loop();

    if (millis() - printLocationLast >= printLocationPeriod.count()) {
        printLocationLast = millis();

        LocationPoint point;
        int err = LocationService::instance().getLocation(point);
        if (err == SYSTEM_ERROR_NONE) {
            Serial.printlnf("lat=%.5f lng=%.5f speed=%.2f locked=%d", point.latitude, point.longitude, point.speed, point.locked);
        }

    }
}


I am encountering a similar problem to one I had earlier while trying to figure this out. The values it outputs are all 0.

That's expected until the device gets a GNSS lock. It probably will not be able to get a lock indoors.

I placed it in a better spot, and it appears to be working now, thank you for you help!

1 Like