Open christian-nils opened 1 year ago
Thanks for the issue, it's on my list and I'll get to this issue if not today, then tomorrow!
Thank you for looking into that. From my long investigation during the last days, I can see the following points (in the case you use MFIO as interrupt line):
It seems that by default there is some averaging done on the data points as I retrieve always half of the number of points for the configured sampling frequency (I can see from the MAX30101 datasheet that this is the default anyway, I will try to decrease that number and see if it changes anything). EDIT: changing the sample averaging value in the MAX30101 register 0x08, makes the trick. I could reach 1600 samples/s but it is a bit unstable. For the other configurations, no issues (e.g. set sampling frequency 1600Hz and sampling average of 32 gives me raw data at a rate of 50Hz). These are the functions I used for updating the sample averaging:
// This function modifies the sample averaging of the MAX30101.
// Default: 2 sample averaging.
// Register: 0x08, bits [7:5]
// SMP_AVE[2:0] - NO. OF SAMPLES AVERAGED PER FIFO SAMPLE
// 000 - 1 (no averaging)
// 001 - 2
// 010 - 4
// 011 - 8
// 100 - 16
// 101 - 32
uint8_t Max32664Hub::set_sample_averaging(uint8_t sample_averaging)
{
uint8_t bits;
uint8_t reg_val;
// Make sure the correct pulse width is selected.
if (sample_averaging <= 5)
{
bits = sample_averaging << 5;
}
else
{
return INCORR_PARAM;
}
// Get current register value so that nothing is overwritten.
reg_val = read_register_max30101(MAX30101_FIFO_CONFIG_REGISTER);
reg_val &= SAMP_AVG_MASK; // Mask bits to change.
reg_val |= bits; // Add bits
write_register_max30101(MAX30101_FIFO_CONFIG_REGISTER, reg_val); // Write Register
return SUCCESS;
}
// This function reads the register (0x08), bits [7:5] from the
// MAX30101 Sensor. It returns the sample averaging setting.
uint8_t Max32664Hub::read_sample_averaging()
{
uint8_t reg_val;
reg_val = read_register_max30101(MAX30101_FIFO_CONFIG_REGISTER);
reg_val &= READ_SAMP_AVG_MASK;
return reg_val >> 5;
}
Anyway, maybe some stuff is wrong (or everything), but I thought that it was worth mentioning those results if it helps. I will use the "counter" from the payload to sync the data.
Thanks for the follow up, this may help quite a bit. This library has a few open issues that I'd like to tackle simultaneously as they have a common thread with the ESP32 platform. Unfortunately I got bludgeoned with illness last week and I'll need to do some catch up on my current projects before I get to this. I expect I'll have some time midweek. Talk to you soon.
Thanks for following up :-) I hope you are feeling fine again, take care and good luck with all the catching-up! Let me know if I can help in any ways!
I suspect it has something to do with the "CMD_DELAY" being significantly reduced in later firmware releases but I still need to test with a board that has the latest firmware which I do not have. This is still ongoing, thank you for your patience.
Hi,
Thanks for this library. I bought the oximeter sensor from Sparkfun (https://www.sparkfun.com/products/15219). I am trying to read the IR led count data but there are some periodic gaps in the data. Here is a short excerpt of the Serial monitor: https://pastebin.com/85jETjyG
Here is a graph showing periodic plateaus in the data (which are typically just gaps in data as the ESP32 is just polling the same value until a new value is available).
I have the same behaviour when reading the data only on interrupt and when the data ready flag is set to 1 (I am using ESP-IDF for that test):
The code I used when using the Arduino library is the following:
Any idea why I get those periodic gap in the raw data?
Thanks in advance!