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

    random OSError: I2C bus error with VLX053

    Scheduled Pinned Locked Moved Issues & Bugs
    oserror i2cbus error
    4 Posts 2 Posters 941 Views 2 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.
    • N Offline
      nalexopo
      last edited by nalexopo

      Hello,

      I am running this library for vl53l0x
      https://bitbucket.org/thesheep/micropython-vl53l0x/src/9077f84e25409532b7ef220fa068605c971ba967/vl53l0x.py?at=default&fileviewer=file-view-default

      and that is what I run as a test

      import time
      import gc 
      from machine import I2C
      import vl53l0x
      
      i2c = I2C(0, I2C.MASTER, baudrate=100000)
      #gc.enable()
      # Initialize I2C bus and sensor.
      vl53 = vl53l0x.VL53L0X(i2c)
      
      
      while True:
          range=vl53.read()
          print(range)
          print("free mem : ")
          print(gc.mem_free())
          
          time.sleep(0.1)
      

      I tried running it in the hardware I2c and in random pins. I tried various delays. I monitored the memory. Whatever I do I just get randomly OSError: I2C bus error that crashes everything, after a few minutes of proper operation.

      Is there a way to bypass the error and not crash?

      sebS 1 Reply Last reply Reply Quote 0
      • sebS Offline
        seb @nalexopo
        last edited by

        @nalexopo

        I have literally just finished a project using this sensor and let me say it is extremely picky.

        I found that the the i2c communication falls over very quickly if you touch any of the wires when its running (and trust me, I painstakingly checked every wire and solder join to make sure it was solid), from that point onward the module seems to fail to respond. The only way to bring it back is to completely unpower the device and try again. I also slowed down the i2c baud rate just in case that made it worse.

        N 1 Reply Last reply Reply Quote 0
        • N Offline
          nalexopo @seb
          last edited by nalexopo

          I certainly dont touch wires when it fails as I leave it working on my desk at night. I was testing it with an adafruit break out board as well. Now i am testing it with my own break out board without regulators and level shifter circuits I will see how it is going.

          I have to point out that I already ran the project with the same sensor on stm32 with the official stm C libraries without stability problems. So I guess its not the sensor.

          Do you use the same library as me?

          sebS 1 Reply Last reply Reply Quote 0
          • sebS Offline
            seb @nalexopo
            last edited by

            @nalexopo

            Yep I used that library and the pololu breakout board. I can't really give you an exact explanation as to what was going on because I didn't connect the signals to a logic analyser/oscilloscope but the only way I could get the module to start responding was with a full reboot. The sensor is very complex and the library doesn't fully implement everything, and my guess is it doesn't recover from errors very well requiring the full reboot. It works really reliably if I don't fiddle with the wires and make sure it has a clean boot.

            Try lowering your baud rate like I did:

            i2c = I2C(1, pins=('P6', 'P5'), baudrate=5000)
            v = VL53L0X.VL53L0X(i2c)

            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