Skip to content

i2c not working properly unless I import wifi and set a small delay while initializing the i2c variable (See Video) #4472

Closed
@eddieespinal

Description

@eddieespinal

Firmware

Adafruit CircuitPython 6.2.0-beta.1-dirty on 2021-03-22;

Code/REPL

import time
import board
import busio
import wifi # without this import, i2c won't work
import adafruit_mpu6050

i2c = busio.I2C(board.SCL, board.SDA)
time.sleep(1) # without this delay, i2c won't work
mpu = adafruit_mpu6050.MPU6050(i2c, address=0x69)

while True:
    print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2" % (mpu.acceleration))
    print("Gyro X:%.2f, Y: %.2f, Z: %.2f degrees/s" % (mpu.gyro))
    print("Temperature: %.2f C" % mpu.temperature)
    print("")
    time.sleep(1)

Behavior

code.py output:
Traceback (most recent call last):
  File "code.py", line 9, in <module>
  File "adafruit_mpu6050.py", line 144, in __init__
ValueError: No I2C device at address: 69

Description

  • Error while using i2c with any i2c devices or sensors.
  • Only happens when I don't include the import wifi and set a delay while initializing the i2c variable.

I tried using other i2c devices such as 128x64 display, same error same solution to make it work.

Additional Info

Here is a video that shows what I'm describing here.

Adding the import wifi and time.sleep(1) solves the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions