MATLAB Answers

Need help receiving accelerometer data through an I2C connection in MATLAB.

I'm using a Sparkfun LSM9DS1 IMU, and an Arduino Uno. I've set up the arduino connection on MATLAB and have wired the IMU to be compatible for I2C, but am a little lost about how to get the data from this particular IMU off the Arduino and into MATLAB.

  댓글 수: 0

로그인 to comment.

답변 수: 1

Swarooph 님의 답변 29 Jun 2017

Have you looked at this example? It shows how to use the MATLAB Support Package for Arduino Hardware and the I2C interface to communicate with I2C devices. Note that it uses the TMP102 temperature sensor. But I think once you have the IMU wired correctly, the overall process should look the same.

  댓글 수: 3

Thanks for getting me started Swarooph. Unfortunately I followed their scheme using the same wiring configuration and code and am getting data that is a vector of zeros. I tried changing the precision to 'uint16' and that had no effect. Here is my code:
a = arduino();
addrs = scanI2CBus(a)
trial = i2cdev(a, '0x6B')
write(trial, 0, 'uint8');
data = read(trial, 2, 'uint8')
The example you sent me has a 2017a tag at the top. I am using MATLAB 2014b. Might that make a difference?
sir, The above mentioned 5 lines code was not executing.It was showing"Failed to read 2 uint8 value(s) from the device.can please give the executable code or solution for that.
Thanking you

로그인 to comment.

Translated by