GPS-inactive mystery - v1

I have modified the quckstart example by adding a card.location request. But the GPS fails to go active unless I comment out a note send request. I also added a card.time request show that should enable the GPS to start.

What is the problem with the original code that is causing the problem? By the way the original code works in that it is sending data to the hub correctly. Just the GPS never activates.

Orginal code that never activates GPS

J *req = notecard.newRequest("note.add");
if (req != NULL)
{

  JAddStringToObject(req, "file", "sensors.qo");
  JAddBoolToObject(req, "sync", true);
  J *body = JAddObjectToObject(req, "body");
  if (body)
  {
    JAddNumberToObject(body, "temp", temperature);
    JAddNumberToObject(body, "humidity", humidity);
  }
 notecard.sendRequest(req);

}

J* req2 =notecard.newRequest("card.time") ;
notecard.sendRequest(req2) ;


J* req1 = notecard.newRequest("card.location");
notecard.sendRequest(req1) ;

[INFO] {“req”:“card.time”,“crc”:“0003:1110F247”}
[INFO] {“minutes”:-300,“lat”:40.902312499999993,“lon”:-81.382578125,“area”:“Greentown OH”,“country”:“US”,“zone”:“EST,America/New_York”,“time”:1700757685}

[INFO] {“req”:“card.location”,“crc”:“0004:F0AE3444”}
[INFO] {“status”:“GPS inactive {gps-inactive}”,“mode”:“continuous”}

Code that works -first notecard.sendRequest commented out

J *req = notecard.newRequest("note.add");
if (req != NULL)
{

  JAddStringToObject(req, "file", "sensors.qo");
  JAddBoolToObject(req, "sync", true);
  J *body = JAddObjectToObject(req, "body");
  if (body)
  {
    JAddNumberToObject(body, "temp", temperature);
    JAddNumberToObject(body, "humidity", humidity);
  }
 // notecard.sendRequest(req);

}

J* req2 =notecard.newRequest("card.time") ;
notecard.sendRequest(req2) ;


J* req1 = notecard.newRequest("card.location");
notecard.sendRequest(req1) ;

[INFO] {“req”:“card.time”,“crc”:“0009:1110F247”}
[INFO] {“minutes”:-300,“lat”:40.902312499999993,“lon”:-81.382578125,“area”:“Greentown OH”,“country”:“US”,“zone”:“EST,America/New_York”,“time”:1700757732}

[INFO] {“req”:“card.location”,“crc”:“000A:F0AE3444”}
[INFO] {“status”:“GPS search (13 sec, 0/0 dB SNR, 0/0 sats) {gps-active}”,“mode”:“continuous”}

Hi @jderimig,

I’m guessing you have mode:continuous in your hub.set call? If so, this places the cellular radio into continuous mode (maintaining a continuous connection to Notehub). The cellular radio and GPS module can’t be active at the same time, so we recommend using mode:periodic for both hub.set and card.location.mode requests. Take a look at the full docs here: Time & Location Requests - Blues Developers

Hope that helps - if not, just let us know!

Thanks,
Rob

Hi Rob, belated happy thanksgiving.

I had the hub.set to periodic and gps to continuous. Let me try setting both to continuous and try that.

Current setup.

 J *req = notecard.newRequest("hub.set");
  JAddStringToObject(req, "product", productUID);
  JAddStringToObject(req, "mode", "periodic");
  notecard.sendRequest(req);
  

  J* req1 = notecard.newRequest("card.location.mode");
  JAddStringToObject(req1,"mode","continuous");
 // JAddIntToObject(req1,"seconds",10) ;
  notecard.sendRequest(req1); 

No joy…

Temperature = 20.12 *C
Humidity = 47.28 %
[INFO] {“req”:“note.add”,“file”:“sensors.qo”,“sync”:true,“body”:{“temp”:20.125,“humidity”:47.2843017578125},“crc”:“0033:1DC0E152”}
[INFO] {“total”:1}

[INFO] {“req”:“card.time”,“crc”:“0034:1110F247”}
[INFO] {“minutes”:-300,“lat”:40.902312499999993,“lon”:-81.382578125,“area”:“Greentown OH”,“country”:“US”,“zone”:“EST,America/New_York”,“time”:1700860186}

[INFO] {“req”:“card.location”,“crc”:“0035:F0AE3444”}
[INFO] {“status”:“GPS inactive {gps-inactive}”,“mode”:“periodic”}

Hi @jderimig,

You definitely don’t want both in continuous mode as at least one has to be in periodic (otherwise your device will again be in conflict as it tries to continually switch between cell/GPS with neither working well or at all). Here’s a host of things I would look at:

  1. Are you giving it time to get a satellite fix? It can take up to 1-2 minutes to switch from cell to GPS and get a satellite fix.
  2. Is the GPS antenna firmly seated on the Notecard?
  3. Does the device have a clear view of the southern sky (assuming you are in the northern hemisphere)?
  4. This shouldn’t be an issue since it doesn’t seem like you can get an initial GPS fix, but the Notecard does have to sense movement w/ the onboard accelerometer for it to try and get a new location. Never hurts to jostle it a bit when testing, just to make sure.
  5. Remove the sync:true from any note.add requests.
  6. Check out the Cold Chain Monitor accelerator app for an example of this in action. Might be some code you can get inspired by.
  7. Try the same requests as you pasted above, but add an explicit outbound to the hub.set call:
J *req = notecard.newRequest("hub.set");
JAddStringToObject(req, "product", productUID);
JAddStringToObject(req, "mode", "periodic");
JAddIntToObject(req,"outbound",30); // 30 minutes in this acse
notecard.sendRequest(req);

J* req1 = notecard.newRequest("card.location.mode");
JAddStringToObject(req1,"mode","continuous");
notecard.sendRequest(req1); 

It would also help to know what exactly you’re trying to accomplish, as it’s a balancing act between enabling cell vs GPS (i.e. do you want to gather location more frequently or sync data to the cloud more frequently?).

HI Rob,

Getting a GPS fix is not an issue. When the first note send request is commented out the card.location immediately responses with “GPS searching” status and a fix is obtained about 1-2 minutes later as the ephemeris data is downloaded. When the earlier send request is in the code the card.location response never gets to “GPS searching” and status is always “GPS inactive”.

The application sends data and status from a vehicle’s flight computer to the cloud and I would like to merge it with the notecard’s GPS data. This would save me from adding an external GPS to the flight computer. I don’t need continuous GPS data but location fixes every 10-15 seconds would be required.

I will try your code suggestions and see what happens. I appreciate your help.

Ok interesting. When you say “location fixes every 10-15 seconds would be required”, that is effectively “continuous” as far as the Notecard is concerned :slight_smile:.

In this scenario, here is how I would start to approach the code:

  1. In hub.set, set the outbound to a high number, like 60 (so you’ll sync data once every hour).
  2. Leave card.location.mode in continuous mode.
  3. If you’re gathering location data (presumably creating notes) every 10-15 seconds, you should definitely use templated Notefiles to save space in flash on the Notecard.

If you can connect to the in-browser terminal you can try issuing trace +gps to see a log of communications with the GPS module when it says it’s inactive.

Also, my colleague Zak wrote an elegant little method that effectively forces the Notecard to get a GPS fix (or fail gracefully). Might be worth checking out: https://github.com/zfields/EpiCAT/blob/main/EpiCAT.ino#L49