
< MAX30102 모듈 작동 원리 >
▷ 통합 발광체: 내부의 적색 LED와 적외선(IR) LED가 빛을 발사한다.
▷ 광검출기: 혈액 내 헤모글로빈이 빛을 흡수하고 남은 반사광을 측정한다.
▷ 데이터 변환: 내부의 저소음 아날로그-디지털 변환기(ADC)가 신호를 디지털 데이터로 변환한다.
▷ 통신 방식: 표준 I2C 인터페이스를 사용하여 선 2개(SDA, SCL)로 데이터를 전송한다.
★ MAX30102 라이브러리 설치 하면 예제가 있다
File --> Examples --> SparkFun MAX3010x Pulse and Proximity Sensor Library --> Example1_Basic_Readings
---< MAX30102_Basic- Reading.ino >-------------------------------------------------------------------------
#include <Wire.h>
#include "MAX30105.h"
MAX30105 particleSensor;
#define debug Serial //Uncomment this line if you're using an Uno or ESP
//#define debug SerialUSB //Uncomment this line if you're using a SAMD21
void setup()
{
debug.begin(9600);
debug.println("MAX30105 Basic Readings Example");
// Initialize sensor
if (particleSensor.begin() == false)
{
debug.println("MAX30105 was not found. Please check wiring/power. ");
while (1);
}
particleSensor.setup(); //Configure sensor. Use 6.4mA for LED drive
}
void loop()
{
debug.print(" R[");
debug.print(particleSensor.getRed());
debug.print("] IR[");
debug.print(particleSensor.getIR());
debug.print("] G[");
debug.print(particleSensor.getGreen());
debug.print("]");
debug.println();
}
---------------------------------------------------------------------------------------------------
---< MAX30102_HeartRate.ino >----------------------------------------------------------------
#include <Wire.h>
#include "MAX30105.h"
MAX30105 particleSensor; // initialize MAX30102 with I2C
void setup() {
Serial.begin(115200);
while(!Serial); //We must wait for Teensy to come online
delay(100);
Serial.println("");
Serial.println("MAX30102");
Serial.println("");
delay(100);
// Initialize sensor
if (particleSensor.begin(Wire, I2C_SPEED_FAST) == false) //Use default I2C port, 400kHz speed
{
Serial.println("MAX30105 was not found. Please check wiring/power. ");
while (1);
}
byte ledBrightness = 70; //Options: 0=Off to 255=50mA
byte sampleAverage = 1; //Options: 1, 2, 4, 8, 16, 32
byte ledMode = 2; //Options: 1 = Red only, 2 = Red + IR, 3 = Red + IR + Green
int sampleRate = 400; //Options: 50, 100, 200, 400, 800, 1000, 1600, 3200
int pulseWidth = 69; //Options: 69, 118, 215, 411
int adcRange = 16384; //Options: 2048, 4096, 8192, 16384
//Configure sensor with these settings
particleSensor.setup(ledBrightness, sampleAverage, ledMode, sampleRate, pulseWidth, adcRange);
}
void loop() {
particleSensor.check(); //Check the sensor
while (particleSensor.available()) {
// read stored IR
Serial.print(particleSensor.getFIFOIR());
Serial.print(",");
// read stored red
Serial.println(particleSensor.getFIFORed());
// read next set of samples
particleSensor.nextSample();
}
}
-------------------------------------------------------------------------------------------------------------------------