SparkFun Pulse Oximeter and Heart-Rate Sensor. The sensor is an I²C based biometric sensor, utilising two chips from Maxim Integrated: the MAX32664 Bio Metric Sensor Hub and the MAX30101 Pulse Oximetry and Heart-Rate Module.
pulse-oximeter
@/pulse-oximeter
SparkFun Pulse Oximeter and Heart-Rate Sensor. The sensor is an I²C based biometric sensor, utilising two chips from Maxim Integrated: the MAX32664 Bio Metric Sensor Hub and the MAX30101 Pulse Oximetry and Heart-Rate Module.
I2Cxod/i2c/i2c
I²C bus.
Resetport
Reset pin.
MFIOport
Multi-function input/output pin.
UPDpulse
Update. Trigger read.
Donepulse
Pulse on read.
exStatnumber
Finger detection status extended. 0 = success, 1 = not ready, -1 = object detected, -2 = excessive sensor device motion, -3 = no object detected, -4 = pressing too hard, -5 = object other than finger detected, -6 excessive finger motion.
Statusbyte
Finger detection status. 00h = no object detected, 01h = object detected, 02h = object other than finger detected, 03h = finger detected.
Confnumber
Sensor's confidence in the reported data. Range: 0 to 100%.
SpO2number
Oxygen saturation (%).
BPMnumber
Heart rate (beats per minute).
To use the node in your project you should have the wayland/sparkfun-pulse-oximeter library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.
C++ implementation
// Tell XOD where it can download the libraries:
#pragma XOD require "https://github.com/sparkfun/SparkFun_Bio_Sensor_Hub_Library"
// Include C++ libraries
#include <SparkFun_Bio_Sensor_Hub_Library.h>
#include <Wire.h>
node {
meta {
using Type = SparkFun_Bio_Sensor_Hub*;
}
static_assert(isValidDigitalPort(constant_input_Reset), "must be a valid digital port");
static_assert(isValidDigitalPort(constant_input_MFIO), "must be a valid digital port");
SparkFun_Bio_Sensor_Hub bioHub = SparkFun_Bio_Sensor_Hub(constant_input_Reset, constant_input_MFIO);
void evaluate(Context ctx) {
if (isSettingUp()) {
auto wire = getValue<input_I2C>(ctx);
if (bioHub.begin(*wire)!=0){
raiseError(ctx);
return;
}
if (bioHub.configBpm(MODE_TWO)!=0){
raiseError(ctx);
return;
}
// allow time for buffer to be loaded with data
delay(4000);
}
if (isInputDirty<input_UPD>(ctx)) {
bioData body;
body = bioHub.readBpm();
emitValue<output_BPM>(ctx, body.heartRate);
emitValue<output_SpO2>(ctx, body.oxygen);
emitValue<output_Conf>(ctx, body.confidence);
emitValue<output_Status>(ctx, body.status);
emitValue<output_exStat>(ctx, body.extStatus);
emitValue<output_Done>(ctx, 1);
}
}
}