MAX30102是一款基于PPG((PhotoPlethysmoGraphy)的集成脈搏血氧儀和心率監測生物傳感器模塊。體積小,可以戴在手指或手腕上進行數據采集。內部集成18bit ADC,傳感器支持I2C 數據輸出,可兼容大多數控制器。
- /*!
- * @file basicRead.ino
- * @brief Output readings of red light and IR
- * @n This library supports mainboards: ESP8266, FireBeetle-M0, UNO, ESP32, Leonardo, Mega2560
- * @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
- * @licence The MIT License (MIT)
- * @author [YeHangYu](hangyu.ye@dfrobot.com)
- * @version V0.1
- * @date 2020-05-29
- * @url https://github.com/DFRobot/DFRobot_MAX30102
- */
- #include <DFRobot_MAX30102.h>
- DFRobot_MAX30102 particleSensor;
- /*
- Macro definition opions in sensor configuration
- sampleAverage: SAMPLEAVG_1 SAMPLEAVG_2 SAMPLEAVG_4
- SAMPLEAVG_8 SAMPLEAVG_16 SAMPLEAVG_32
- ledMode: MODE_REDONLY MODE_RED_IR MODE_MULTILED
- sampleRate: PULSEWIDTH_69 PULSEWIDTH_118 PULSEWIDTH_215 PULSEWIDTH_411
- pulseWidth: SAMPLERATE_50 SAMPLERATE_100 SAMPLERATE_200 SAMPLERATE_400
- SAMPLERATE_800 SAMPLERATE_1000 SAMPLERATE_1600 SAMPLERATE_3200
- adcRange: ADCRANGE_2048 ADCRANGE_4096 ADCRANGE_8192 ADCRANGE_16384
- */
- void setup()
- {
- //Init serial
- Serial.begin(115200);
- /*!
- *@brief Init sensor
- *@param pWire IIC bus pointer object and construction device, can both pass or not pass parameters (Wire in default)
- *@param i2cAddr Chip IIC address (0x57 in default)
- *@return true or false
- */
- while (!particleSensor.begin()) {
- Serial.println("MAX30102 was not found");
- delay(1000);
- }
- /*!
- *@brief Use macro definition to configure sensor
- *@param ledBrightness LED brightness, default value: 0x1F(6.4mA), Range: 0~255(0=Off, 255=50mA)
- *@param sampleAverage Average multiple samples then draw once, reduce data throughput, default 4 samples average
- *@param ledMode LED mode, default to use red light and IR at the same time
- *@param sampleRate Sampling rate, default 400 samples every second
- *@param pulseWidth Pulse width: the longer the pulse width, the wider the detection range. Default to be Max range
- *@param adcRange Measurement Range, default 4096 (nA), 15.63(pA) per LSB
- */
- particleSensor.sensorConfiguration(/*ledBrightness=*/0x1F, /*sampleAverage=*/SAMPLEAVG_4, \
- /*ledMode=*/MODE_MULTILED, /*sampleRate=*/SAMPLERATE_400, \
- /*pulseWidth=*/PULSEWIDTH_411, /*adcRange=*/ADCRANGE_4096);
- }
- void loop()
- {
- //Print result
- Serial.print("R=");
- /*!
- *@brief Get red value
- *@return Red light reading
- */
- Serial.print(particleSensor.getRed());
- Serial.print(" IR=");
- /*!
- *@brief Get IR value
- *@return IR reading
- */
- Serial.print(particleSensor.getIR());
- Serial.println();
- delay(100);
- }
復制代碼 |