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 library

    Scheduled Pinned Locked Moved Discussion
    pytrackgpslibrarygps pytrack
    11 Posts 3 Posters 1.7k Views 3 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.
    • J Offline
      jcaron @tttadam
      last edited by

      @tttadam

      You may want to get a look at:

      • https://github.com/inmcm/micropyGPS
      • https://github.com/andrethemac/L76GLNSV4/blob/master/L76GNSV4.py

      Note that both are linked to in the Pytrack examples page.

      T 1 Reply Last reply Reply Quote 1
      • T Offline
        tttadam @jcaron
        last edited by

        @jcaron Yes you are right, I wasn't profound enough.
        micropyGPS looks really powerful. However, It's not clear for me how to use it.
        Because this library for uart, but pytrack use I2c am I missing something?
        Is there a sample code where I can start? micropyGPS use predifined gps sentences.
        Thanks in advance.

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

          @tttadam micropyGPS does not handle the I/O, it's up to you to feed it the data using the update function.

          You'll find an example here: https://github.com/gregcope/L76micropyGPS

          The core of it is really just:

              while True:
                  # get some NMEA data
                  someNmeaData = str(self.i2c.readfrom(GPS_I2CADDR, 128))
          
                  # Pass NMEA data to micropyGPS object
                  for x in someNmeaData:
                      self.my_gps.update(str(x))
                  time.sleep(0.25)
          
          T 1 Reply Last reply Reply Quote 1
          • T Offline
            tttadam @jcaron
            last edited by

            @jcaron Thank you.

            1 Reply Last reply Reply Quote 0
            • T Offline
              tttadam
              last edited by

              I am having some issues with L76micropyGPS.py library, if I want to use the I2C.
              When I create an I2C object in the main.py

              i2c=I2C(0, I2C.MASTER)
              

              I got an OSError: I2C bus error in L76micropyGPS.py at line 54.
              I think it because me and the library both want to use I2C. But I would like to work with a temperature sensor wich communicates in I2C, and later I would like to chain other envirement sensors (as far as I know I can use multiple external sensor on the same pins. )

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

                @tttadam unless you provide the full code you are using and full details of what is connected where there’s very little chance anybody is going to be able to help you.

                T 1 Reply Last reply Reply Quote 0
                • T Offline
                  tttadam @jcaron
                  last edited by tttadam

                  @jcaron Fair enough, sorry. :)

                  This is how my boot.py looks like,
                  the GPS set up is from line 50 to 60. This part is run alright, expect some rare cases minor issues with the rtc setup:

                  # # this runs first
                  # #TODO: CLEAN IT up, SD Class(inprogress),
                  import pycom
                  import os
                  import math
                  import machine
                  from machine import SD, Pin, UART
                  from pytrack import Pytrack
                  import utime
                  import time
                  import _thread
                  import gc
                  from L76micropyGPS import L76micropyGPS
                  from micropyGPS import MicropyGPS
                  #my classes
                  from  rgbsignal import RGBSignal
                  from sdlogger import SDLogger
                  
                  uart = UART(0, baudrate=115200)
                  os.dupterm(uart)
                  
                  #TODO:test it, 	outsource it
                  runcount = pycom.nvs_get('runcount')
                  print("The current value of the run counter is: "+str(runcount))
                  pycom.nvs_set('runcount', runcount+1)
                  
                  # this is the led notification class
                  fb = RGBSignal() 
                  
                  #the main file will be called
                  machine.main('main.py')
                  
                  #buttonpin = Pin('G17', mode= Pin.IN, pull=Pin.PULL_UP) #button pin on expansion board
                  buttonpin = Pin('G4', mode= Pin.IN, pull=Pin.PULL_UP) #button pin on pytrack board
                  start = True
                  print("Push the button for start booting")
                  #def message(self, color="cyan", interval=0.5, iteration=3):
                  _thread.start_new_thread(fb.message, ["cyan",0.1,0.3])
                  while start:
                      utime.sleep_ms(10)
                      if buttonpin() == 0:
                          start = False
                  _thread.start_new_thread(fb.startup, [])
                  print("Boot file process is started.")
                  
                  gc.enable()
                  print("GC is enabled")
                  print("Free Mem: {}".format(gc.mem_free()))
                  
                  #Setting up the gps:
                  py = Pytrack()
                  my_gps = MicropyGPS(local_offset=1,location_formatting='dd')
                  L76micropyGPS = L76micropyGPS(my_gps, py)
                  gpsThread = L76micropyGPS.startGPSThread()
                  print("Waiting for gps signal")
                  counter = 0
                  while (my_gps.timestamp == (0, 0, 0)):
                      print("Waiting for gps signal: "+str(counter)+" "+str(my_gps.date)+" "+str(my_gps.timestamp))
                      counter +=1
                      time.sleep(2)
                  time.sleep(4)
                  print("Date: "+str(my_gps.date))
                  print("GPS signal is found")
                  print("Time: "+str(my_gps.timestamp))
                  time.sleep(2)
                  print(my_gps.date[0])
                  print(my_gps.date[1])
                  print(my_gps.date[2])
                  
                  
                  print("Setting up the RTC")
                  rtc = machine.RTC()
                  print("RTC before init: {}".format(rtc.now()))
                  dateYear = int(str(20) + str(my_gps.date[2]))
                  rtc.init((dateYear, my_gps.date[1], my_gps.date[0], my_gps.timestamp[0], my_gps.timestamp[1], int(my_gps.timestamp[2]), 0, 0)) #seting up the rtc 
                  print("RTC is set : {}".format(rtc.now()))
                  
                  
                  
                  
                  #Create logstructure after GPS initalizaed
                  dataLogger = SDLogger(uart)
                  dataLogger.sdFormat()
                  foldername = str("Flight_"+
                               str(runcount)+"_"+
                               str(dateYear)+"-"+
                               str(my_gps.date[1])+"-"+
                               str(my_gps.date[0])+"_"+
                               str(my_gps.timestamp[0])+"-"+
                               str(my_gps.timestamp[1])+"-"+
                               str(int(my_gps.timestamp[2])))
                  
                  dataLogger.createFolder(foldername)
                  logfilename = str("LogOfRun"+"_"+
                            str(runcount)+"_"+
                            str(dateYear)+"-"+
                            str(my_gps.date[1])+"-"+
                            str(my_gps.date[0])+"_"+
                            str(my_gps.timestamp[0])+"-"+
                            str(my_gps.timestamp[1])+"-"+
                            str(int(my_gps.timestamp[2])))
                  logheader = "TimeStamp;GPSTimeStamp;Sensor;Value;Location"
                  dataLogger.creatLogFile(logheader,logfilename)
                  # #TODO: Create separate log for sytemlog, telemetry, and sensor data
                  

                  After the boot.py main.py is next, This fails at line 30, when I create the I2C object. With an OSError: I2C bus error in L76micropyGPS.py at line 54.

                  from machine import I2C, Pin, UART
                  import machine
                  from SI7021 import SI7021
                  import gc
                  import _thread
                  #my classes
                  from  rgbsignal import RGBSignal
                  from sdlogger import SDLogger
                  
                  
                  start = True
                  buttonpin = Pin('G4', mode= Pin.IN, pull=Pin.PULL_UP) #button pin on pytrack board
                  _thread.start_new_thread(fb.message, ["yellow",0.1,3])
                  print("Push the button for start main")
                  while start:
                      time.sleep_ms(10)
                      if buttonpin() == 0:
                          start = False
                  _thread.start_new_thread(fb.startup, [])
                  
                  
                  print("Main has started")
                  print("Free Mem: {}".format(gc.mem_free()))
                  i2c=I2C(0, I2C.MASTER)
                  print(i2c.scan())
                  
                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    tttadam
                    last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      tttadam
                      last edited by

                      I found the issue.
                      I gave my I2C object an ID = 1, and that solved the issue.

                      G 1 Reply Last reply Reply Quote 0
                      • G Offline
                        gregcope @tttadam
                        last edited by gregcope

                        @tttadam Hi. Looks like you might have found my L76micropyGPS.py useful. Any feedback welcome! I just updated the doco as the issue has been resolved, and I had not updated the README.

                        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