I2C Bus Errors



  • 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...
    


  • 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



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

    A resistor between the i2c can solve this problem.



  • @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



  • @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)



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

    Do you use an resistor between the i2c bus?



  • @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?



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


Log in to reply
 

Pycom on Twitter