Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    PyTrack GPS Lock

    Scheduled Pinned Locked Moved Expansion Board
    pytrackgpsaccuracy
    14 Posts 6 Posters 3.6k Views 7 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      peekay123 @pymiom
      last edited by

      @pymiom, note that I modified the GPS library to decode different messages. Nonetheless, the ability to lock is independent of that.

      1 Reply Last reply Reply Quote 0
      • P Offline
        pymiom
        last edited by

        Hello,

        Thanks for the advice so far :)

        I just have a deep sleep board in between the two but I believe this may not be needed after reading some other posts.

        When I am back with the board in the next few days I will give it another try.

        Thanks!

        1 Reply Last reply Reply Quote 0
        • J Offline
          jinjiro
          last edited by

          @pymiom I'm using a SiPy with the PyTrack and my experience so far is similar.
          I'm using firmware 1.17.3.b1 on the SiPy and 0.0.8 for the PyTrack which seem to be the most recent for both.

          Indoors I find that it is difficult te get a fix, even when placing the board near a window.

          Perhaps my code is not good enough to get a quicker/better fix.

          This is what I use in main.py:

          import machine
          import math
          import network
          import os
          import time
          import utime
          import socket
          import struct
          from network import Sigfox
          from machine import RTC
          from machine import SD
          from machine import Timer
          from L76GNSS import L76GNSS
          from pytrack import Pytrack
          
          # setup as a station
          import gc
          
          time.sleep(2)
          gc.enable()
          init_timer = time.time()
          
          # setup rtc
          rtc = machine.RTC()
          rtc.ntp_sync("pool.ntp.org")
          utime.sleep_ms(750)
          print('\nRTC Set from NTP to UTC:', rtc.now())
          utime.timezone(7200)
          print('Adjusted from UTC to EST timezone', utime.localtime(), '\n')
          py = Pytrack()
          l76 = L76GNSS(py, timeout=30)
          chrono = Timer.Chrono()
          chrono.start()
          sd = SD()
          os.mount(sd, '/sd')
          f = open('/sd/gps-record.txt', 'w')
          
          while(True):
              # time-counter configurations
              final_timer = time.time()
              diff = final_timer - init_timer
              # save the coordinates in a new variable
              coord = l76.coordinates()
              #coord = (43.345543, 7.890123)  # test coords instead of waiting for fix
              # verify the coordinates received
              if coord == (None, None):
                  print("Getting Location...")
                  continue
              # SigFox time wait (max 1 msg/10 mins)
              # diff <= 600 takes 10 min approximately to send the next message. Use 10 for testing.
              if diff <= 10 and coord != (None, None):
                  print("Waiting to send the next Sigfox message")
                  continue
              # write coords to sd card
              f.write("{} - {}\n".format(coord, rtc.now()))  # save coords SD card
              # send the Coordinates to Sigfox
              s.send(struct.pack("<f", float(coord[0])) + struct.pack("<f", float(coord[1])))
              print(struct.pack("<f", float(coord[0])) + struct.pack("<f", float(coord[1])))  # temp to see what s.send transmits
              print("Coordinates sent -> lat: " + str(coord[0]) + ", lng: " + str(coord[1]))
              # reset the timer
              time.sleep(5)
              init_timer = final_timer
          
          1 Reply Last reply Reply Quote 0
          • P Offline
            pymiom
            last edited by

            Hey @jinjiro ,

            My code is more or less the same as yours (excluding the SD card write)!!

            Like you, I am only wanting to send the coordinates to sigfox...

            Does anyone have any feedback on the code, or can see any issues with it?

            Thanks

            J 1 Reply Last reply Reply Quote 0
            • J Offline
              jinjiro @pymiom
              last edited by jinjiro

              It would also help if someone knows how to make the current status more visible, more verbose.

              Why are the coords stuck on "none, none" for so long, is it because of the weak signal strength, how many sats did it find (none, or 2 or just waiting on the last one).

              I'm learning as I go and my skills in python are not quite there yet, any help is very much appreciated.

              1 Reply Last reply Reply Quote 0
              • A Offline
                agmatthews
                last edited by

                @jinjiro @pymiom Have a look at https://forum.pycom.io/topic/2992/pytrack-gps-library-only-works-with-glonass-derived-positions
                It may be that the reason that you see (None, None) is the L76GNSS library is not decoding GPS only sentences (ie it does not decode GPS fixes without GLONASS)

                J 1 Reply Last reply Reply Quote 0
                • J Offline
                  jinjiro @agmatthews
                  last edited by jinjiro

                  @agmatthews Thx for posting, I've changed the line to GPGLL but unfortunately it did not make a difference here compared to GNGLL. Still stuck on (None, None) for a long time. I replaced GNGLL for GPGLL, maybe that's not correct?

                  On the topic of using micropyGPS, it is a rather large lib (29kb compared to the L76 is 3kb, and yes I know it is not as complete but still) and I get a "MemoryError: memory allocation failed, allocating 342 bytes" on my SiPy board.

                  Do you use micropyGPS on a SiPy or on a different Pycom?

                  J robert-hhR 2 Replies Last reply Reply Quote 0
                  • J Offline
                    jinjiro @jinjiro
                    last edited by

                    update: The idea of using micropyGPS as a "frozen module" is interesting and a little more advanced than my current level ...

                    Found this page specifically for the Pycom SiPy (but I assume it works for all Pycom boards): https://mjuenema.github.io/iot/pycom_sipy_sigfox/firmware_upgrade/

                    1 Reply Last reply Reply Quote 1
                    • robert-hhR Offline
                      robert-hh @jinjiro
                      last edited by

                      @jinjiro If you get the memory error during import, you can try to precompile the module with mpy-cross. I have a pre-built version here: https://github.com/robert-hh/Shared-Stuff/blob/master/mpy-cross_pycom.exe or here https://github.com/robert-hh/Shared-Stuff/blob/master/mpy-cross_pycom_linux
                      Sorry, no OS X version. These tools create a .mpy file out of a .py file, which can be import like the .py file.
                      @seb: How about providind precomiled versions of mpy-cross at least for Windows and OS X. The Linux folks should be able to handle that themselves.

                      J 1 Reply Last reply Reply Quote 1
                      • J Offline
                        jinjiro @robert-hh
                        last edited by jinjiro

                        @robert-hh Thx, work kept me a bit busy but found some time to play today.

                        I went the micropyGPS frozen module route. I've been running into issue after issue trying to get the dev environment up on OSX. So had to deploy a ubuntu box with all the tools first and flashed the new firmware from there.

                        Preliminary tests show that the frozen module and the code works. Obtaining a GPS lock indoors not really yet however I need to look into it further. At least now I have more data/cmds to start troubleshooting.

                        I have a Pi Zero with attached GPS module, 3G dongle and external GPS antenna which gets a GPS lock indoors fairly quickly and is using 3G to transmit coords so that's my benchmark. My goal is to downsize this tracker to sipy-pytrack-sigfox.

                        Thx all for the pointers and support.

                        1 Reply Last reply Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • 1 / 1
                        • First post
                          Last post

                        Pycom on Twitter

                        Pycom