Hi all, how do I find out my sampling rate? My code uploaded to the arduino does several things, one of which is to pick up pressure fluctuations through a microphone into analog port A4, and I seem to be getting uneven rates of samples transferred into excel.
In one second I'd have 5 different readings for voltage/current/mic reading, but in another I'd have 3. Is my sampling rate unstable or does it pick up readings only when there's a noticable change?
Still quite new to arduino, thanks so much for the help
this is an example of what my results tend to look like. as you can see i get different number of samples every other second so i can't quite figure out what my sampling rate is
Rather than printing out the constant "DATA,DATE,TIME" + ....
why not try printing out the actual time so you have a timestamp on every data point you receive. You can use the millis() function which will return the number of milliseconds that have elapsed since the program started. Not exactly a date/time, but you will be able to see how much time has elapsed between readings.
You get the sampling rate by determining the time difference between two samples.
That depends on lots of things, like whether, how much and how fast you print or transmit the sample information, whether you unwisely use String objects, etc.
Railroader:
Is it possible to speed up the communication? Serial.begin(9600) changed to Serial.begin(115200)? Would that give more space for Your loop?
I tried that, and weird things came out on my serial monitor instead...my arduino gives me just one reading every two seconds now..argh
You have to change your serial monitor baud rate to match your code. That little box at the bottom of your image still says 9600. If you code is at 115200, that needs to match.
Serial communication is accomplished with interrupts so the code doesn't really block waiting for the entire line to be transmitted before continuing so I'm not surprised it didn't help.
I'm afraid it is your sensor that is the bottleneck