How do I read real time values from the GY-85 IMU sensor at Simulink connected via Arduino? Also, I intend to interact with the Virtual Reality environment at Simulink using this GY-85 IMU sensor. Is this possible? How do I make MATLAB read real time values from this GY-85 IMU sensor connected to Arduino via I2C communication ? Please help!


Interfacing with Simulink has sometimes been a pain, I've developed a method to simplify it by putting a middle-man app between the arduino and Simulink:

  • Read the IMU data from the Arduino and print it in comma delimited ASCII
    • This Arduino library can help you with reading the IMU from the Arduino.
    • Your Arduino application would simply read from the IMU, and send the data over serial or TCP/IP.
  • Read the ASCII string, convert it to a known binary structure and publish it on a TCP/IP port.
    • An excellent utility to do this is 'csv-to-bin' and 'io-publish' from the comma library.
    • An example command-line would be "cat /dev/ttyACM0 | csv-to-bin 9f | io-publish tcp:9000", which would read from the serial device /dev/ttyACM0 (assuming you're on linux) then convert the comma-delimited string to a binary struct consisting of 9 floats, then publish it on TCP port 9000.
  • In Simulink, use the TCP read block with the binary structure you selected.
    • In your Simulink model you can use blocks from the Instruments Control Toolbox to read the data. You must set the data types and sizes in the structure being read.

The advantage of using ASCII in step 1 is that you don't have to worry about the binary representation of the data when reading from the IMU or Arduino, and you can then explicitly convert that data into your selected binary structure for reading with Simulink.

| improve this answer | |
  • $\begingroup$ This is an interesting way to do it. Is there any other way which does not involve use of TCP / IP ? $\endgroup$ – Ajinkya Padwad Jan 17 '16 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.