Description
The MAX30102 is an integrated pulse oximetry and heart-rate monitor module. It includes internal LEDs, photodetectors, optical elements, and low-noise electronics with ambient light rejection. The MAX30102 provides a complete system solution to ease the design-in process for mobile and wearable devices. Communication is through a standard I2C-compatible interface. The module can be shut down through software with zero standby current, allowing the power rails to remain powered at all times.
Specification:
- Tiny Board Size:12.7mm x 12.7mm (0.5in x 0.5in)
- Form Color: Purple
- Working Voltage:3.3V – 5v ( Recommended to use 3.3v)
Applications:
- Wearables
- Heart-rate monitor
- Pulse oximeter
Hardware required:
- MAX30102 Sensor
- Arduino UNO
- Breadboard
- Jumper wires
Connecting the Hardware
Setting up the Arduino IDE
- Download and Install the Arduino IDE
- Go to Tools > Board > Board Manager
- Type Arduino AVR Board and Click Install, Also install ESP8266 board when using nodemcu ESP8266 module in your Arduino IDE.
- If boards are not in the Board Manager, Go to file > Preferences
- Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json (For ESP8266 module), https://github.com/dmadison/ArduinoXInput_AVR.git (For Arduino) , press OK
- Repeat step 3 to install the board.
Installing the Library
- Go to , Tools > Manage Libraries
- Type “MAX30102″ and install the one by SparkFun Electronics as shown below or download it here
See how to install library here
Upload the Sample Sketch
#include <Wire.h>
#include “Adafruit_MAX30102.h”
Adafruit_MAX30102 sensor;
void setup() {
Wire.begin();
Serial.begin(115200);
while (!Serial);
if (!sensor.begin()) {
Serial.println(“MAX30102 not found!”);
while (1);
}
Serial.println(“MAX30102 initialized.”);
}
void loop() {
int IR, red;
if (sensor.check()) {
IR = sensor.getIR();
red = sensor.getRed();
Serial.print(“IR: “); Serial.print(IR);
Serial.print(” Red: “); Serial.println(red);
Serial.print(“Mean Diff: “);
Serial.println(meanDiff(IR));
}
delay(10);
}
long meanDiff(int M) {
#define LM_SIZE 15
static int LM[LM_SIZE];
static byte index = 0;
static long sum = 0;
static byte count = 0;
long avg = 0;
sum -= LM[index];
LM[index] = M;
sum += LM[index];
index = (index + 1) % LM_SIZE;
if (count < LM_SIZE) count++;
avg = sum / count;
return avg – M;
}