Sampling Rate vs Character Length

Hi guys,

I have a project on interfacing a software called Labview with arduino. I am kinda new to arduino programming but the project requires me to use it. Currently i use an arduino nano with bno055 attached to measure absolute orientation.

My issue is with the serial communication. The sample rate at which labview receives data is varying at large amounts (for example i set delay 1ms the frequency will range from 110-170hz). I figured this is due to the limited buffer size of the arduino and the varying number of characters sent to labview via the serial communication. when i move the bno sensor in a certain orientation it will produce a data with higher significant value than some other orientation and this ,I figured, creates the varying sample rate.

So my question is, is there a way to limit the amount of characters sent in serial.print function? (for example 34.52 will become 034.52 and 342.3 will become 342.30)

Or is there any other way to fix the rate of serial communication?
Code attached

test6.ino (3.41 KB)

So my question is, is there a way to limit the amount of characters sent in serial.print function? (for example 34.52 will become 034.52 and 342.3 will become 342.30)

Yes. Use sprintf() to format the string the way you want.

char *result = malloc(5);

WTF? If that succeeds, the result is NO different from using a real array with 5 elements.