2021-03-23 10:38 AM
I'm trying to do a Project with the MAX30102. I can read out the raw data of the sensor but I am unable to understand the algorithm to calculate the Heartrate and SPO2 out of the raw data. The only examples I can find are for Arduino Boards but that's not useful at all. I found this one Example for the STM32F103C8T6 and I was hoping I could just convert it for my board so at least I got something that works...
Here is the link for the example:
https://www.programmersought.com/article/90827305857/
I have the code in the attachment.
I hope somebody can help me.
best regards,
F.Enis
2021-03-23 01:44 PM
Nice find but I see two problems:
How this will impact you if you don't use the KEIL compiler tool chain I have no idea
You should just use F466RE in Cube and try it! If you don't have the MAX30102 yet Adafruit has one and Mouser many - Mouser has the MAX Feather shield with the device.
;)
FYI MAX has a repository on mbed with this device and mbed has the Nuleco-F446RE supported.
2021-03-24 04:24 AM
Thanks for the reply.
The problem is that I tried it but can't get anything to work.
I found this website: https://morf.lv/implementing-pulse-oximeter-using-max30100
The author is doing the processing for the MAX30100 but the same principles should apply for the MAX30102. The problem is that I have problems converting the code he used for my Project. I am not that good at programming to be honest:grinning_face_with_sweat:.
I have my main file in the attachment. Maybe somebody could help me a little because I'm already really frustrated:o)
best regards,
F.Enis
2024-09-29 11:42 AM
hey did u get ur output working?
2024-09-29 01:34 PM
From 3 years ago, try it yourself..
Read the data sheet. F1 and F4 are architecturally different. The HAL provides for a rough equivalence, and should be relatively fungible.
2024-12-12 11:38 PM
Hi,
When reading the FIFO buffer though I2C read command, we typically retrieve 6 bytes of data: 3 bytes for the Red LED value and 3 bytes for the IR LED value.
The question is: how is the data arranged in the 6-byte buffer?
Is it organized such that bytes 0 to 2 represent the Red LED data, and bytes 3 to 5 represent the IR LED data?
I'm a bit confused about how the data is arranged when reading multiple bytes. Could you clarify the orientation of the data in the buffer?
uint8_t maxim_max30102_read_fifo(uint32_t *pun_red_led, uint32_t *pun_ir_led)
/**
* \brief Read a set of samples from the MAX30102 FIFO register
* \par Details
* This function reads a set of samples from the MAX30102 FIFO register
*
* \param[out] *pun_red_led - pointer that stores the red LED reading data
* \param[out] *pun_ir_led - pointer that stores the IR LED reading data
*
* \retval true on success
*/
{
uint32_t un_temp;
unsigned char uch_temp;
*pun_red_led=0;
*pun_ir_led=0;
unsigned char ach_i2c_data[6];
//read and clear status register
maxim_max30102_read_reg(REG_INTR_STATUS_1, &uch_temp);
maxim_max30102_read_reg(REG_INTR_STATUS_2, &uch_temp);
ach_i2c_data[0]=REG_FIFO_DATA;
HAL_I2C_GetState(&hi2c1);
//DMP library driver slave_addr address needs to be shifted 1 bit to the left when sending, the last bit or upper read/write bit
HAL_I2C_Mem_Read(&hi2c1, I2C_READ_ADDR, REG_FIFO_DATA, 1, ach_i2c_data, 6, HAL_MAX_DELAY);
un_temp=(unsigned char) ach_i2c_data[0];
un_temp<<=16;
*pun_red_led+=un_temp;
un_temp=(unsigned char) ach_i2c_data[1];
un_temp<<=8;
*pun_red_led+=un_temp;
un_temp=(unsigned char) ach_i2c_data[2];
*pun_red_led+=un_temp;
un_temp=(unsigned char) ach_i2c_data[3];
un_temp<<=16;
*pun_ir_led+=un_temp;
un_temp=(unsigned char) ach_i2c_data[4];
un_temp<<=8;
*pun_ir_led+=un_temp;
un_temp=(unsigned char) ach_i2c_data[5];
*pun_ir_led+=un_temp;
*pun_red_led&=0x03FFFF; //Mask MSB [23:18]
*pun_ir_led&=0x03FFFF; //Mask MSB [23:18]
return 1;
}