Dear All,
I am experiencing problems with an IMU which I recently purchased. I am controlling the LSM9DS1 breakout board with a Raspberry Pi’s I²C digital interface. I have soldered connectors onto the board and connected the VDD pin to the 3.3 Volt rail of the pi, the GND pin to ground and the SDA and SCL wires to the respective pins on raspberry pi. I am using the python programming language with the smbus module to control the unit. However, the gyroscope is only giving noise readings for data, which isn’t changing according to any angular momentum I apply to the unit, whereas the accelerometer is reading perfectly. Here is the code I am using:
import time, smbus
bus = smbus.SMBus(1) # I am using this bus, i2cdetect -y 1 shows the device at 0x6B
# Turn on Gyroscope and Accelerometer, ODR = 119Hz, 245dps
bus.write_byte_data(0x6B, 0x10, 0b01100000)
print(bin(bus.read_byte_data(0x6B, 0x17))) # returns 0b111: data is available
while True:
# read data from the x-axis of the gyroscope.
# All the addresses here are the IMU's output registers.
data0 = bus.read_byte_data(0x6B, 0x18)
data1 = bus.read_byte_data(0x6B, 0x19)
xGyro = data1*256+data0 # format from two's complement
data0 = bus.read_byte_data(0x6B, 0x1A)
data1 = bus.read_byte_data(0x6B, 0x1B)
yGyro = data1*256+data0
data0 = bus.read_byte_data(0x6B, 0x1C)
data1 = bus.read_byte_data(0x6B, 0x1D)
zGyro = data1*256+data0
data0 = bus.read_byte_data(0x6B, 0x28)
data1 = bus.read_byte_data(0x6B, 0x29)
xAccel = data1*256+data0
data0 = bus.read_byte_data(0x6B, 0x2A)
data1 = bus.read_byte_data(0x6B, 0x2B)
yAccel = data1*256+data0
data0 = bus.read_byte_data(0x6B, 0x2C)
data1 = bus.read_byte_data(0x6B, 0x2D)
zAccel = data1*256+data0
# Accelerometer data is fine, Gyroscope is not changing apart from noise,
# bus still reporting that new data is available.
time.sleep(0.01)
print(bin(bus.read_byte_data(0x6B, 0x17))) # returns 0b111: new data
print(xGyro, yGyro, zGyro, xAccel, yAccel, zAccel)
I have read through the data sheet and tried this with two units, both with the same result.
I would really appreciate a solution to this problem.
Many Thanks in Advance.