Reference
Last revision 2025/12/17
The article serves as a reference for understanding various libraries and communication protocols used in sensors, particularly focusing on heart rate, blood oxygen, and temperature data collection using Arduino and Raspberry Pi, along with CRC check algorithms and setup instructions.
Library
- RTU Library (Modbus RTU protocol library for Arduino)
- Heart Rate Sensor Library and Sample Codes Library (for Arduino, follow installation guide)
- Heart Rate Sensor Python Library (for Raspberry Pi)
Communication Protocol Description
Note: The communication interface uses UART
| Transmit | From Adevice to Bdevice | ||||
|---|---|---|---|---|---|
| Functions | Bdevice Addess | Function Code | Register Address | Register Number | CRC Check |
| Get the Heart Rate and Blood Oxygen Data | 0×20 | 0×03/Read | 0×00 0×06 | 0×00 0×04 | CRC_h CRC_l |
| Get the Temperature | 0×20 | 0×03 | 0×00 0×0A | 0×00 0×01 | CRC_h CRC_l |
| Receive | Response from Bdevice | ||||
| Functions | Bdevice Addess | Function Code | Valid Bytes | Data | CRC Check |
| Get the Heart Rate and Blood Oxygen Data | 0×20 | 0×03 | 0×08 | SPO2(1byte) xx(1byte reseved) Heartbeat(4byte) xx(2byte reserved) | CRC_h CRC_l |
| Get the Temperature | 0×20 | 0×03 | 0×02 | Temp_h Temp_l | CRC_h CRC_l |
| Set the Sensor | Transmit From Adevice | ||||
|---|---|---|---|---|---|
| Functions | Bdevice Addess | Function Code | Register Address | Register Number | CRC Check |
| Start to Collet Data | 0×20 | 0×06 | 0×00 0×10 | 0×00 0×01 | CRC_h CRC_l |
| Stop Colleting Data | 0×20 | 0×06 | 0×00 0×10 | 0×00 0×02 | CRC_h CRC_l |
| Set the Sensor | Response From Bdevice | ||||
| Functions | Bdevice Addess | Function Code | Valid Bytes | Data | CRC Check |
| Start to Collet Data | 0×20 | 0×06 | 0×00 0×10 | 0×00 0×01 | CRC_h CRC_l |
| Stop Colleting Data | 0×20 | 0×06 | 0×00 0×10 | 0×00 0×02 | CRC_h CRC_l |
CRC check
static uint16_t calculate_CRC(uint8_t *data, uint8_t len)
{
uint16_t crc = 0xFFFF;
for( uint8_t pos = 0; pos < len; pos++)
{
crc ^= (uint16_t)data[ pos ];
for(uint8_t i = 8; i != 0; i--)
{
if((crc & 0x0001) != 0){
crc >>= 1;
crc ^= 0xA001;
}else{
crc >>= 1;
}
}
}
crc = ((crc & 0x00FF) << 8) | ((crc & 0xFF00) >> 8);
return crc;
}
API Description
/*!
* @brief Get heart rate and oxygen saturation and store them into the structure sHeartbeatSPO2
* @param NULL
* @return No value returned
*/
void getHeartbeatSPO2();
/*!
* @brief Get the sensor board temp
* @param NULL
* @return Temp (unit: ℃)
*/
float getTemperature_C();
/*!
* @brief Sensor starts to collect data
* @param NULL
* @return NULL
*/
void sensorStartCollect();
/*!
* @brief Sensor stops collecting data
* @param NULL
* @return NULL
*/
void sensorEndCollect();
Principle
The MAX30102 uses PPG(PhotoPlethysmoGraphy) to measure data, which will be converted into heart rate and oximetry values when processed by the MCU.
Other Supplementary Information
Wear Instructions

Use Guide for the Master Computer
Connect the sensor to the USB-to-serial port module.

Click to download the master computer of SEN0344 Heart Rate and Oximeter Sensor.
After decompressing, run SEN0344.exe, select the serial port and baud rate and click to start the measurement.

Was this article helpful?
