Advice?: Not getting GPS lock

Howdy All

Just got the Swan and have the latest firmware and Circuit Python on it, with note carrier F. At this point I am able to connect to the cellular network and send data to NoteHub, but not able to get a lock on GPS. I have put it near a window as well as moved in to my deck with a clear view of the sky (clear, cold evening and day) .

I have followed this link the GPS tutorial and this link – (performed all the steps).

For comparison, I do have a small GPS module that I got from AMZN also. It is able to get a lock (it’s not 100% perfect, but it does latch on to GPS - even near the window). I also tried swapping the antennae w/o any luck.

I am curious are there any other troubleshooting steps that I could take? I also tried both
continuous mode and the periodic mode (60 seconds) and trying moved the swan a bit, such that it knows that it made some motion…

I am powering the swan with exactly 5V using an external power supply with a dial.

P.S I’ve also included some sample uPython code below (periodic gps) to show what I’m doing…

Any help would be great, thanks!
John

######################## Sample Code ########################

import notecard
import board
import busio
import time
import json

prodid="$my_prod_id"
port = busio.I2C(board.SCL, board.SDA)
card = notecard.OpenI2C(port, 0, 0, debug = True)

##Setup mod
req = {"req": "hub.set"}
req["product"] = prodid
req["mode"] = "continuous"
rsp = card.Transaction(req)

while True:
    #Check the time
    req = {"req": "card.time"}
    rsp = card.Transaction(req)
    if rsp['zone'] is not 'UTC,Unknown':
        print("OK - Cellular Data Gotten")
        break
    else:
        print("NOTOK - Cellular Data not Gotten - trying again")
        time.sleep(2)
    
def send_data_notehub(data):
    req = {"req": "note.add"}
    req["file"] = "sensors.qo"
    req["sync"] = True
    req["body"] = data
    rsp = card.Transaction(req)
    
req = {"req": "card.location.mode"}
req["mode"] = "periodic"
req["seconds"] = 60
rsp = card.Transaction(req)
        
while True:
    req = {"req": "card.location"}
    rsp = card.Transaction(req)
    lat = rsp.get('lat')
    lon = rsp.get('lon')
    if lat and lon:
        print(f"OK - GPS Data lat: {lat} lon: {lon}")
        #send_data_notehub({ "lat": lat, "lon": lon})
    else:
        #send_data_notehub({ "No": "GPS"})
        print('NOTOK - No GPS data')
    print("rsp:",rsp)
    print(time.localtime())
    time.sleep(60)

As an update, I am now getting:

|Mon 06:50:09 PM|$mycity|dev:860322068102265|_geolocate.qo||
| — | — | — | — | — | — | — |
||{“country”:“US”,“location”:“$mycity”,“radios”:{“wifi”:16}}|

in Notehub. I don’t recall seeing that in NoteHub before, But I do recall seeing it trying to get location via cellular… I am not explicitly sending that to NoteHub, so maybe that’s something the Swan does on it own like the boot messages.

For GPS you need to connect first to the cellular network. Then only it will start and get the fix.
I had the same issue before, but I then desided to use GPS data from cellular network only.

Hey John, and welcome to the Blues community!

What you have there looks reasonable, so to start, can you tell me:

  • What Notecard SKU are you using?
  • You said you’re running the latest firmware, but can you quickly confirm that by running {"req":"card.version"} and ensure you have 5.3.1?
  • What specific anteanna(s) have you tried?

And just for some background, the _geolocate.qo Notefile is automatically created when triangulation is enabled on the Notecard. (See System Notefiles - Blues Developers) Wi-Fi triangulation is enabled by default on Notecards with Wi-Fi capabilities.

TJ

Hi TJ,

Thanks for the replies and suggestions:

card.Transaction({"req":"card.version"})
{"req": "card.version"}
{'body': {'ver_major': 5, 'version': 'notecard-u5-5.3.1', 'ver_patch': 1, 'ver_build': 16292, 'ver_minor': 3, 'target': 'u5', 'org': 'Blues Wireless', 'built': 'Sep 17 2023 20:32:47', 'product': 'Notecard'}, 'version': 'notecard-5.3.1.16292', 'sku': 'NOTE-WBNAW', 'name': 'Blues Wireless Notecard', 'wifi': True, 'device': 'dev:860322068102265', 'gps': True, 'board': '5.13', 'api': 5, 'cell': True}
{'body': {'ver_major': 5, 'version': 'notecard-u5-5.3.1', 'ver_patch': 1, 'ver_build': 16292, 'ver_minor': 3, 'target': 'u5', 'org': 'Blues Wireless', 'built': 'Sep 17 2023 20:32:47', 'product': 'Notecard'}, 'version': 'notecard-5.3.1.16292', 'sku': 'NOTE-WBNAW', 'name': 'Blues Wireless Notecard', 'wifi': True, 'device': 'dev:860322068102265', 'gps': True, 'board': '5.13', 'api': 5, 'cell': True}
  • Antennas I tried were the shipped one of course but also a few ufl one’s like this - just for some data points:

Understood on the _geolocate.qo file…Thanks

That is my understanding as well. Thanks

Hey @jouell,

I did some asking around internally. The issue here is likely because you have your cellular connection set to continuous ({"req":"hub.set","mode":"continuous"}) AND have such a low interval for taking GPS readings through card.location.mode.

To test, can you try changing your cellular connection to periodic ({"req":"hub.set","mode":"periodic"}) and see if that helps you find a location?

TJ

Thanks TJ

I updated it to be:

##Setup mod
req = {“req”: “hub.set”}
req[“product”] = prodid
##req[“mode”] = “continuous”
req[“mode”] = “periodic”
rsp = card.Transaction(req)

also dropped the period to 10 (I thought 60 was low) :

req = {“req”: “card.location.mode”}
req[“mode”] = “periodic”
req[“seconds”] = 10
rsp = card.Transaction(req)

Unfortunately did not get the lock…The little gps device did get a lock though (via my window) :

Hey @jouell,

If you attempt to sample GPS every 10 seconds the Notecard is never going to have a chance to make a cellular connection.

Still though I would’ve expected you to have been able to get a connection by now. Could you try capturing a trace while running card.location in the in-browser terminal and seeing if you get any log messages that might help us debug this?

TJ

Howdy - does this help?

import notecard
import board
import busio
import time
import json
prodid="com.gmail.jouellnyc:gps"
port = busio.I2C(board.SCL, board.SDA) 
card = notecard.OpenI2C(port, 0, 0, debug = True)
req = {"req":"card.trace","mode":"on"}
card.Transaction(req)

{“mode”: “on”, “req”: “card.trace”}
{‘stop’: True}
{‘stop’: True}

req = {"req":"hub.set","mode":"periodic"}
card.Transaction(req)
{"body": {"os_family": "Swan R5 with STM32L4R5ZIY6", "req_interface": "i2c", "os_name": "circuitpython", "os_platform": "Swan R5", "agent": "note-python", "os_version": "3.4.0", "req_port": 0}, "mode": "periodic", "req": "hub.set"}
req = {'req': 'card.location.mode'}
req["mode"] = "periodic"
req["seconds"] = 60
card.Transaction(req)

{“seconds”: 60, “mode”: “periodic”, “req”: “card.location.mode”}
{‘seconds’: 60, ‘mode’: ‘periodic’}
{‘seconds’: 60, ‘mode’: ‘periodic’}

req = {"req": "card.location"}
card.Transaction(req)

{“req”: “card.location”}
{‘mode’: ‘periodic’, ‘status’: ‘GPS inactive {gps-inactive}’}
{‘mode’: ‘periodic’, ‘status’: ‘GPS inactive {gps-inactive}’}

req = {"req":"card.trace","mode":"off"}
card.Transaction(req)

{“mode”: “off”, “req”: “card.trace”}
{‘stop’: True}
{‘stop’: True}

import os
os.listdir()

[‘.fseventsd’, ‘.metadata_never_index’, ‘.Trashes’, ‘settings.toml’, ‘code.py’, ‘lib’, ‘boot_out.txt’, ‘main.py’]