# Frequency of Data Collection - BNO055

I'm working on a project using an Aduino Uno, Adafruit Data Logger Shield, Adafruit Prototype Shield, and Adafruit 9-DOF Absolute Orientation IMU (BNO055). I'm having issues understanding/adjusting the frequency at which data is being collected and recorded.

Just for some background info, my device reads quaternion values, converts them to Euler angles, and saves this data to an SD card.

Looking at this page on the Adafruit website for the BNO055, Quaternion and Euler data should be output at a frequency of 100 Hz or 0.01 seconds; the datasheet also supports this.

Is my understanding that within my sketch for my device the following line should control the delay between collected samples of data:

``````// set delay between data
#define BNO055_SAMPLERATE_DELAY_MS (100)
``````

With that line set to 100 ms, my delay between output data should effectively be 10 Hz.

Am I understanding correctly that the BNO055 is reading and outputting data at a frequency of 100 Hz, but because I have my sample rate set to 10 Hz, I am actually saving the data to my SD card at a frequency of 10 Hz?

I have the data saved from my data logger shield being imported to a MATLAB program I made. Within my MATLAB program, I split the time from the text file. Looking at the time array (with the sample rate set in the sketch to 100 ms), the average difference between consecutive logged time values is 0.1351 seconds which is effectively 7.4 Hz.

Is there anyway to get the logging frequency closer to the 10 Hz that I believe it is set to? I can post more code if needed.

Yes, change the delay to 10ms for 100 Hz.

The problem with the delay(10) at the end of the loop() function is everything else in the loop takes non-zero amount of time. For example, if the reading of the IMU and writing to SD takes 5 milliseconds, a delay(10) means data is read and stored every 15 ms. Compute the amount of time to do read and store the data then subtract from 10 to get the corrected delay time. I have no idea how long it takes to actually read and write the data. I just made up some numbers for the example.

Thanks for the help. That makes sense that the offset is caused by the Uno looping through all the other functions within the main sketch. I will work on figuring out approximately how long it takes to loop through it all then correct for the offset in the delay function.