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 sample code

    Scheduled Pinned Locked Moved Getting Started
    pytrack
    32 Posts 5 Posters 4.1k Views 5 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.
    • A Offline
      abhishek2101 @dan
      last edited by

      @dan
      can you share the code you used.

      danD 1 Reply Last reply Reply Quote 0
      • danD Offline
        dan @abhishek2101
        last edited by

        @abhishek2101 I'm using our Pytrack example: https://github.com/pycom/pycom-libraries/blob/master/pytrack/main.py

        1 Reply Last reply Reply Quote 0
        • A Offline
          abhishek2101 @dan
          last edited by

          @dan
          I am outside with pytrack having access to open sky.

          following is the code

          from L76GNSS import L76GNSS
          from pytrack import Pytrack
          py = Pytrack()
          l76 = L76GNSS(py, timeout=30)
          while (True):
          
              coord = l76.coordinates()
              print(coord)
          

          still after 20 minutes I only see (none, none).

          One only I saw coordinate values but that came in after approx 40 minutes.

          How are we suppose to use pytrack if it takes so long to lock onto satellites (that too, not always) or am I missing anything. Please help.

          A C 2 Replies Last reply Reply Quote 0
          • A Offline
            abhishek2101 @abhishek2101
            last edited by

            @abhishek2101 said in pytrack sample code:

            @dan
            I am outside with pytrack having access to open sky.

            following is the code

            from L76GNSS import L76GNSS
            from pytrack import Pytrack
            py = Pytrack()
            l76 = L76GNSS(py, timeout=30)
            while (True):
            
                coord = l76.coordinates()
                print(coord)
            

            still after 20 minutes I only see (none, none).

            One only I saw coordinate values but that came in after approx 40 minutes.

            How are we suppose to use pytrack if it takes so long to lock onto satellites (that too, not always) or am I missing anything. Please help.

            need to fix this asap, can somebody help.

            1 Reply Last reply Reply Quote 0
            • C Offline
              crumble @abhishek2101
              last edited by

              @abhishek2101 said in pytrack sample code:

              I am outside with pytrack having access to open sky.

              You have to learn more about the GPS stuff. The pycom library is very basic, you have to know more anyway or have to use a third party library.

              You need wide area of clear sky, nice weather and no noise on the frequencies. It needs some time for the GPS chip to see enough satellites for a triangulation. If you just outside a building or next to a steep mountain, you may be in the shadow of this obstacle.

              Your phone will do some tricks. First it guesses your position from the last call. It uses a frequently loaded file of statellite positions to reduce search time. Additional it may guess your postion by lookng for a set of known WiFis and their signal strength.

              The pycom module does none of this tricks. So locking needs longer. In some cases a better antenna or a better position will solve the connection problem, but there is no connector for an external antenna :(

              1 Reply Last reply Reply Quote 1
              • J Offline
                jcaron @abhishek2101
                last edited by

                @abhishek2101 said in pytrack sample code:

                @dan
                Google maps on my iPhone shows my location at the same place within few seconds.

                Apples and oranges.

                A pure GPS device (like the Pytrack) needs to following to find its position:

                • the almanac, which gives a list of their satellites, their orbits, correction parameters, etc.
                • signal from at least 4 satellites, from which it will derive their position (ephemeris) and differential time of arrival.

                The full almanac takes at least 12.5 minutes to receive (provided you can actually receive the signal from at least one satellite), as the GPS signal has very very low bandwidth (50 bits/s) and only a small part of it is available for the almanac. Note that those 12.5 minutes start from the time the GPS receiver has locked onto at least one satellite, which may take a while as well.

                Locking on satellites may take a few minutes. It's a lot faster once you have an almanac and know your approximate position as you'll know which satellites should be visible. Otherwise it's just a matter of scanning for them. The almanac is also required for correction data.

                A phone does several things very differently, because it has access to the Internet. The GPS is actually often used as a last resort:

                • first, it uses nearby cell towers and Wi-Fi APs. It sends a list of what it "sees" to a server, which in turn gives it a position. This is often done in the background, so when you start the app, the phone actually already knows its position. Depending on the environment, this position may be very accurate, or a lot less. This is visible with the "circle of confidence" shows in maps (the light blue disc around the small blue dot). In dense urban environments, it's usually nearly as precise as GPS, and it works indoors.

                • if the phone decides to actually use the GPS chip, it can retrieve the almanac (and more) from the Internet instead of receiving it over GPS

                • it already knows its approximate position, so it makes it easier to select satellites to scan for

                • once if has locked onto satellites, it will adjust the position it thought it had with the (usually) more precise GPS location.

                Now, back to the "pure GPS" Pytrack: it is normal for it to take a while especially at first (not sure if/how the chip actually saves data for future uses), as it needs to receive the almanac, and find satellites. Once it has locked on enough satellites, it should be able to deliver a position pretty quickly.

                You should probably try to dump more information from the GPS chip so see what's going on. Also note that the L76GNSS.py module is pretty basic (for instance it only parses GPS data, while the chip is capable of using other GNSS). You should explore alternatives, such as:

                • micropyGPS
                • this alternative L76GNSS module
                J 1 Reply Last reply Reply Quote 1
                • J Offline
                  jcaron @jcaron
                  last edited by

                  @dan it may make sense to add links to those libraries in the documentation (tutorials and reference).

                  Actually, reading https://forum.pycom.io/topic/2992/pytrack-gps-library-only-works-with-glonass-derived-positions again, the Pycom lib only listens for GLONASS signals (GNGLL) and ignores GPS signals (GPGLL). This should definitely be fixed. It's probably a matter of adding something like:

                  if gngll_idx < 0:
                      gngll_idx = nmea.find(b'GPGLL')
                  

                  just after line 58. Didn't try it (don't have a Pytrack).

                  danD 1 Reply Last reply Reply Quote 0
                  • danD Offline
                    dan @jcaron
                    last edited by

                    @jcaron I've added the links to the docs, thanks. I've also opened an issue about adding support for GPGLL.

                    A 1 Reply Last reply Reply Quote 0
                    • A Offline
                      abhishek2101 @dan
                      last edited by

                      @dan
                      so which libraries I should use ?

                      danD 1 Reply Last reply Reply Quote 0
                      • danD Offline
                        dan @abhishek2101
                        last edited by

                        @abhishek2101 you can try both, whichever works

                        A 1 Reply Last reply Reply Quote 0
                        • A Offline
                          abhishek2101 @dan
                          last edited by

                          @dan
                          can you link them here please.

                          danD 1 Reply Last reply Reply Quote 0
                          • danD Offline
                            dan @abhishek2101
                            last edited by

                            @abhishek2101 they're linked below in @jcaron's post:

                            ...
                            You should probably try to dump more information from the GPS chip so see what's going on. Also note that the L76GNSS.py module is pretty basic (for instance it only parses GPS data, while the chip is capable of using other GNSS). You should explore alternatives, such as:

                            • micropyGPS
                            • this alternative L76GNSS module
                            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
                            • 2
                            • 2 / 2
                            • First post
                              Last post

                            Pycom on Twitter

                            Pycom