Hi,
I currently use an OpenMV M7 with the recent firmware update for a visual/inertial odometry project.
I tried to connect a Drotek 6050MPU (slave address 0x69) using the openMV build in I2C. But when I run the an exemple code, i got an error : OSError: [Errno 110] ETIMEDOUT
So i check if my IMU is still functional on my aduino and it work with no problem…
Do you have any idea…?
from pyb import I2C
ACCEL_XOUT0 = const(0x3B)
ACCEL_YOUT0 = const(0x3D)
ACCEL_ZOUT0 = const(0x3F)
GYRO_XOUT0 = const(0x43)
GYRO_YOUT0 = const(0x45)
GYRO_ZOUT0 = const(0x47)
# Wake up board
addr = 0x69
i2c = I2C(2)
i2c.init(I2C.MASTER)
i2c.mem_write(0x01, addr, 0x6b)
i2c.mem_write(0b00011000, addr, ACCEL_CONFIG)
i2c.mem_write(0b00011000, addr, GYRO_CONFIG)
# helper for converting 2 bytes to int.
btoi = lambda msb, lsb: (msb << 8 | lsb) if not msb & 0x80 else -(((msb ^ 255) << 8) | (lsb ^ 255) + 1)
accel_range = 16.0
accel_rate = 2048.0
gyro_range = 2000.0
gyro_rate = 16.4
accel = [0.0] * 3
gyro = [0.0] * 3
# init buffers
adata = bytearray(6)
gdata = bytearray(6)
# Start loop
while True:
i2c.mem_read(adata, addr, ACCEL_XOUT0)
i2c.mem_read(gdata, addr, GYRO_XOUT0)
accel = [btoi(adata[0], adata[1])/accel_rate, btoi(adata[2], adata[3])/accel_rate, btoi(adata[4], adata[5])/accel_rate]
gyro = [btoi(gdata[0], gdata[1])/gyro_rate, btoi(gdata[2], gdata[3])/gyro_rate, btoi(gdata[4], gdata[5])/gyro_rate]
print('\n\n')
print('accel: ', accel)
print('gyro: ', gyro)
print('\n\n')
delay(300)