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

    I2C Bus Errors

    Scheduled Pinned Locked Moved FiPy
    8 Posts 4 Posters 249 Views 4 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.
    • securigyS Offline
      securigy
      last edited by

      I am reading GPS data using MicroGPS library (much better than native one of Pycom, IMO).
      However, I get frequent I2C Bus Errors. In the reading code below the exception happens multiple times

      Any ideas why am I getting this frequently?

      def ReadInput(self):
      
              print("### Entered ReadInput")
      
              while(True):
                  try:
                      self.raw = self.i2c.readfrom(GPS_I2CADDR, 64) #16)
                      print("Raw data: {}".format(self.raw))
                      # feed into gps object
                      for self.b in self.raw:
                          self.sentence = self.gps.update(chr(self.b))
                          if self.sentence is not None:
                              # gps successfully parsed a message from module
                              # see if we have valid coordinates
                              # This also fills in last_data
                              print("Got sentence!")
                              self.res = self.check_for_valid_coordinates()
                              
                      self.elapsed = chrono.read()
                      if self.elapsed > GPS_TIMEOUT_SECS:
                          break
      
                  except Exception as ex:
                      print("ReadInput loop exception: {}".format(ex.args[0]))                   
      
              print("### Exiting ReadInput...")
      
      
      ### Entered ReadInput
      ReadInput loop exception: I2C bus error
      ReadInput loop exception: I2C bus error
      ReadInput loop exception: I2C bus error
      ReadInput loop exception: I2C bus error
      ReadInput loop exception: I2C bus error
      Raw data: b'57.17932,N,11713.49653,W,0.033,,010320,,,D*75\r\n$GNRMC,032823.00,'
      ### Exiting ReadInput...
      
      1 Reply Last reply Reply Quote 0
      • S Offline
        svonbentzel
        last edited by

        Do you have a sleep between the readings? Maybe you read to fast?

        securigyS 1 Reply Last reply Reply Quote 0
        • securigyS Offline
          securigy @svonbentzel
          last edited by

          @svonbentzel I have sleep(1000) between calling the ReadInput function. I tried having 16- and 32-byte buffer, and 64 worked better but yesterday it did not work so well and neither 128... not sure why... I also tried 3 sec and 5 sec sleep between the function call. Any ideas?

          S 1 Reply Last reply Reply Quote 0
          • S Offline
            svonbentzel @securigy
            last edited by

            @securigy
            What Typ of GPS Sensor you use? Pytrack or an external gps?

            Do you use an resistor between the i2c bus?

            securigyS 1 Reply Last reply Reply Quote 0
            • securigyS Offline
              securigy @svonbentzel
              last edited by

              @svonbentzel I use uBlox GPS dev board "GNSS Click 5" - it has really good GPS with Assist GPS (cold start under 30 sec), and I do not have any resistors in between (I am not an EE... and had no idea I needed one, and if I do where exactly and how big/small)

              robert-hhR S 2 Replies Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @securigy
                last edited by

                @securigy said in I2C Bus Errors:

                You need pull-up resistors for SDA and SCL. The have to be places between each of these signals and 3.3V. Tpyical value range: 4.7 - 10 kOhm. According to the schematics of this board, there are not such resistors, not on the board and not in the NEO-M8 module.

                https://download.mikroe.com/documents/add-on-boards/click/gnss-5/gnss-5-click-schematic-v101.pdf

                1 Reply Last reply Reply Quote 2
                • S Offline
                  svonbentzel @securigy
                  last edited by

                  @securigy the Most i2c errors come from interferences from outside.

                  A resistor between the i2c can solve this problem.

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    Carlos Aldana
                    last edited by

                    For anyone in the future still having these issues, what worked for me (after an embarrassing amount of time trying different fixes) was to change the i2c bus parameter (the first parameter when initializing it) to '2'. See screenshot below.

                    According to the documentation, setting the bus to '2' changes from the hardware driver for i2c to the software driver. And that fixed it for me.

                    Good luck!

                    f798f8e8-f217-4f71-a4ed-cfb1953482d6-image.png

                    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