MAX30102 Heart Rate Oximetry Sensor Module
Module Source
Purchase Link:
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1RFzZhvUyyASrzFopCKZ14A
Password: msbg
Specifications
Operating Voltage:3.3V~5V
Communication Method:I2C
LED Peak Wavelength:660nm/880nm
Operating Temperature: -40℃~85℃
Pin Count: 8(VIN、GND、SCL、SDA、INT、IRD、RD、GND)
Module Dimensions:21mm x 16mm
Hardware Interface
- MAX30102's VCC pin is connected to the 3.3V of the development board.
- The GND pin is connected to the GND of the development board.
- SDA (Serial Data Line) is connected to the A4 (SDA) pin of the development board.
- SCL (Serial Clock Line) is connected to the A5 (SCL) pin of the development board.
- If needed, also connect the INT pin to a digital input pin of the development board to read the interrupt signal.
Usage Method
Install Library
To easily communicate with the MAX30102, you can use a third-party library. There's a library called MAX30105 that can be used to operate the MAX30102, as the two sensors are very similar. This library can be installed via the Arduino IDE's Library Manager. In the Arduino IDE, go to "Tools" > "Manage Libraries...", then search for "MAX30105" and install it.
Enter the code:
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 10, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include <Wire.h>
#include "MAX30105.h"
#include "heartRate.h"
MAX30105 particleSensor;
const byte RATE_SIZE = 4; //Increase this for more averaging. 4 is good.
byte rates[]; //Array of heart rates
byte rateSpot = 0;
long lastBeat = 0; //Time at which the last beat occurred
float beatsPerMinute;
int beatAvg;
void setup()
{
Serial.begin(115200);
Serial.println("Initializing...");
// Initialize sensor
if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port, 400kHz speed
{
Serial.println("MAX30105 was not found. Please check wiring/power. ");
while (1);
}
Serial.println("Place your index finger on the sensor with steady pressure.");
particleSensor.setup(); //Configure sensor with default settings
particleSensor.setPulseAmplitudeRed(0x0A); //Turn Red LED to low to indicate sensor is running
particleSensor.setPulseAmplitudeGreen(0); //Turn off Green LED
}
void loop()
{
long irValue = particleSensor.getIR();
if (checkForBeat(irValue) == true)
{
//We sensed a beat!
long delta = millis() - lastBeat;
lastBeat = millis();
beatsPerMinute = 60 / (delta / 1000.0);
if (beatsPerMinute < 255 && beatsPerMinute > 20)
{
rates[] = (byte)beatsPerMinute; //Store this reading in the array
rateSpot %= RATE_SIZE; //Wrap variable
//Take average of readings
beatAvg = 0;
for (byte x = 0 ; x < RATE_SIZE ; x++)
beatAvg += rates[];
beatAvg /= RATE_SIZE;
}
}
Serial.print("IR=");
Serial.print(irValue);
Serial.print(", BPM=");
Serial.print(beatsPerMinute);
Serial.print(", Avg BPM=");
Serial.print(beatAvg);
if (irValue < 50000)
Serial.print(" No finger?");
Serial.println();
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
Usage Testing
IR refers to pulse, BPM refers to heart rate, and avg BPM refers to average heart rate.