I have some sensors connected to an Arduino Due. The Arduino sends the buffer of data over the its SerialUSB connection. The last element of this buffer defines when are passed 1 seconds (it is 0 "inside" the second and a 1 on the second). In this way, in post processing, I can count the number of the sample revealed each second.
I usually don't lose any data. It doesn't a standard band and, as a consequence, it does not have a stable serial communication time. When I receive the wrong data, I discard it. In addition, the Arduino's clock is not as accurate, so it sometimes time-shifts the data.
What is the best way to stabilize my sampling rate in post processing?
Below is a histogram of the sample rate revealed by an experiment on my Arduino:
X-axis is the number of samples per second, Y-axis is the # of occurrences.
Edit 1:
After some testing, I've noticed an Arduino procedure exists that requires a "variable" amount of time (according to its datasheet, the DS18B20 temperature sensor requires a specific amount of time to collect data and it is "odd" with the second clock).
So, I printed the sample rate (# of samples/second) of my device (without considering the correct data or the wrong data), it appears different each second. Thus, I am considering to interpolate the data and reduce them to a lower sample rate (e.g. 256 each second).