GPS hangs while initialising

I’m using the latest Electron on board GPS module shown here.

I’ve taken the code from the Asset Tracker example,but I’m having problems getting it working.

//----------------- Tracker ----------------//

Adafruit_GPS gps = Adafruit_GPS(&Serial1);

uint8_t internalANT[]={0xB5,0x62,0x06,0x13,0x04,0x00,0x00,0x00,0xF0,0x7D,0x8A,0x2A};
uint8_t externalANT[]={0xB5,0x62,0x06,0x13,0x04,0x00,0x01,0x00,0xF0,0x7D,0x8B,0x2E};

AssetTracker::AssetTracker() {
}

void AssetTracker::gpsOn() {
    // Power to the GPS is controlled by a FET connected to D6
    pinMode(D6,OUTPUT);
    digitalWrite(D6,LOW);
    gps.begin(9600);
    gps.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
    delay(500);
    // Default is 1 Hz update rate
    gps.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // <- Hangs here -----
    delay(500);
    gps.sendCommand(PGCMD_NOANTENNA);
    delay(500);
    //for ublox maxm8 gps only
    //internal antenna selected as default
    for(uint8_t i=0;i<12;i++)
    {
        Serial1.write(internalANT[i]);
    }
    delay(500);
}

void AssetTracker::begin() {
    gpsOn();
}

The code hangs at gps.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); No matter how long I wait it never returns.

Is the Asset Tracker code compatible with this GPS module? Is not, are there other examples out there that work?

You seem to be using the Particle Asset Tracker v2 so I’d strongly suspect that Particles AssetTracker Library works with it :wink:

But I’d suggest you go for the AssetTrackerRK library which uses the TinyGPS++ library.

The AssetTracker v2 does not respond to PMTK commands; those only work with the GlobalTop PA6H GPS receiver in the AssetTracker v1.

The u-blox GPS receiver responds to the PGCMD commands, which are completely different. It usually just ignores the PMTK commands, however, that’s why the AssetTracker library is able to issue both. But you can just remove all of the PMTK commands from your code if they’re causing problems.

So is the AssetTrackerRK library is still the recommended, though unofficial, library for the Particle Asset Tracker v2? And no changes are required for that code; it should just work as is, right?

I haven’t gotten it to work yet, though I’m using a custom daughter board with the UBlox CAM-M8 on the Electron, not the off-the-shelf AssetTracker v2. I’ve successfully used the official AssetTracker 0.0.10 library with the Asset Tracker v1 hardware. I’m trying to figure out if my issue is hardware or software and, having tested without luck the AssetTracker 0.0.10, AssetTracker2 0.2.0, and now AssetTrackerRK 0.1.4 libraries with my Electron & CAM-M8, it seems likely to be a hardware issue.

FWIW, I’m giving the CAM-M8 the 3.3 V from the Electron’s 3V3 pin (tied to VCC, V_BCKP, VCC_IO on the CAM-M8), ground (tied to GND on the CAM-M8), and TX/RX (tied across 220 ohm resistors to RX/TX on the CAM-M8). The D_SEL pin on the CAM-M8 is open as recommended for UART operation. I’ve tried testing outside for 30+ minutes but don’t get anything on the Serial Monitor.

Again, I’m pretty sure it’s hardware-related but just making sure that I didn’t miss something related to software updates for the Asset Tracker v2. Thanks in advance for any tips!

I think so, but @rickkas7 would know best.
AFAIK this lib does not (yet) make use of all the features the ublox module would provide.

1 Like