-
Notifications
You must be signed in to change notification settings - Fork 156
sampling frequency not respected? #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
am using MAX30102 too. Were you able to solve this problem ?? |
no, actually I have tried with another MAX30102 and it showed the same behaviour. I haven't tried with any other MAX3010X module. |
Hi, void loop()
{
particleSensor.check();
for (uint8_t i = particleSensor.available(); i != 0; --i, samplesTaken++) {
Serial.print("[IR] = ");
Serial.print(particleSensor.getFIFOIR());
Serial.print("\t[Red] = ");
Serial.print(particleSensor.getFIFORed());
Serial.print("\n");
particleSensor.check();
particleSensor.nextSample();
}
Serial.print("[Temp] = ");
Serial.print(particleSensor.readTemperature());
Serial.print("\t[Hz] - ");
Serial.print((float)samplesTaken / ((millis() - startTime) / 1000.0), 2);
} |
tldr; I'm confident the library and IC are working correctly. When in doubt read the datasheet! Page 20:
The combination of your pulseWidth, ledMode, and sampleAverage will affect the max sampleRate obtainable. Additionally, off the top of my head, if you've got 2 LEDs active that's 6*3200 = 19,200 bytes that need to be read. At 100kHz I2C you can only read 10,000 bytes per second. Your controller and/or buffers may be the bottleneck. I've added an "Example9" to the library to demonstrate reading 3200 samples per second using a Teensy. Using an Uno I was able to read ~2700Hz. |
Yes, it's likely that the pulse width is too big, haven't thought about it. Also the bottleneck didn't came to my mind. I hope this issue will be useful to others too who struggle with the same problem. |
Hi,
I'm using the MAX30102, but in principle it shouldn't make any difference.
Using the Example6_FiFoReadings code, if I change the sampling frequency I notice that it is not respected.
I have tried changing the sampling rate and the averages together.
Here's a table with some results:
You can see that up to 200Hz it behaves as expected, but from 400Hz and on it seems to completely change its behaviour.
The other parameters were left as usual: pulseWidth = 411 and adcRange = 2048
Any suggestions?
The text was updated successfully, but these errors were encountered: