Communication Speed I2C Wixel App with MiniIMU-9


I am using the Serial to I2c Wixel app to read values from MiniIMU-9 v3. I have modified the MiniIMU-9 library for the Arduino into one for the wixel. I am using serial communication directly from the computer to the Wixel.

There are two issues I am facing. First, when I am reading from either the gyroscope or accelerometer, I am requesting a read from the x low byte value and setting the MSB to 1 so that it performs a sequential read from increasing addresses. Basically, I am requesting the values in this order xLow, xHigh, yLow, yHigh, zLow, zHigh. However, when I receive the data it comes in the order of zHigh, zLow, xHigh, xLow, yHigh, yLow. I have determined this by orientating the sensor. I don’t understand why these values are being rearranged.

Secondly, it currently takes 12 seconds to performed 1000 reads from both the accelerometer and gyroscope. I am curious to what the limiting factor may be. I have not delved very far into the Serial to I2C code and was wondering if anyone has been using the Wixel I2C to receive data at higher rates.

Any help is appreciated. Please let me know what else I can post to help solve the issue.

Thank you


It sounds like you might not be using the original Serial-to-I2C app for the Wixel. Could you post the source code of the program you are running on your Wixel? Also, if you are using a program to handle your MinIMU sensor values from the computer, could you post it here as well?

- Amanda

I am using the Pololu Wixel Configuration Utility to upload the Serial-I2C app to the Wixel. I have not downloaded the source code for the app just the .wxl file from the user manual.

I discovered this issue of the seemingly random order of data being received. It was just an error status byte not being read.

I put together this short example that I believe is replicating the communication speed issue I am having.
This takes a time of about 5 seconds to read. However, for my actual research we are also reading the accelerometer at the same rate and the magnetometer at a reduce rate so the end speed is slower than desired.

#include <windows.h>

using namespace std;

int main()
char* portName = “COM6”;
HANDLE hSerial = CreateFile(portName,
return 1;

int nbChar=8;
DWORD bytesSend;

char command[8];
command[0] = 83;        //Start command
command[1] = 214;       //Write Address I2C
command[2] = 1;         //Always one for a read command
command[3] = (0x28 | 1<<7);       //Register to read from
command[4] = 83;        //Start command
command[5] = 215;       //Read Address I2C
command[6] = 6;   //Bytes to read
command[7] = 80;        //Stop command

DWORD errors;
COMSTAT status;
int i=0;
int nBytesAvailable=0;
while (i<1000)
    WriteFile(hSerial, (void *)command, nbChar, &bytesSend, 0);
        nBytesAvailable = status.cbInQue;
    nBytesAvailable = 0;



It sounds like you are using the Wixel’s Serial-to-I²C App and it is taking an average of 5 milliseconds to read some data from your MinIMU-9 v3. How fast do you want to read the data?

What settings did you choose for the Wixel Serial-to-I²C App? There is a parameter called I2C_freq_kHz that controls the speed of the I²C communication, which defaults to 100. Both chips on the MinIMU-9 v3 are compliant with fast mode (400 kHz) I²C standards, so you could try changing the parameter to 400 and see if that helps. You could also try setting it higher than 400 since our Wixel I²C code tends to overestimate the delays needed between bits, making the signal slower.

I recommend that you don’t use blocking loops like the while(nBytesAvailable<6) one because it could waste CPU time and the call to ClearCommError in the loop might be causing a delay. Instead, I would recommend that you configure the serial port file handle so that you can do blocking reads and writes on it with ReadFile and WriteFile. This means that all the data would be transferred before the function returns and you would not need a loop to wait for the data. We provide some example code for doing this in the “Windows C” section of the Maestro Servo Controller User’s Guide.

When you expand this program to read from the accelerometer, gyro, and accelerometer, you might consider sending all the commands needed to read from those devices with one call to WriteFile. That will probably increase the throughput because all your command bytes can be sent together in one USB packet if they do not exceed 64 bytes in length. Also, you could try reading the results with a single call to ReadFile.

If it is not fast enough after doing all that, you could make your own Wixel app that reads the data and reports it to the computer, avoiding the need to call WriteFile in the PC software.