upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
API for the Pulse oximeter and heart-rate sensor. More...
The MAX30100 is an integrated pulse oximetry and heartrate monitor sensor solution. It combines two LEDs, a photodetector, optimized optics, and low-noise analog signal processing to detect pulse oximetry and heart-rate signals.
I2C sensor which can be used to read: Heart-rate Peripheral capillary oxygen saturation temperature
Public Member Functions | |
MAX30100 (int16_t i2c_bus) | |
virtual | ~MAX30100 () |
max30100_value | sample () |
void | sample_continuous (int gpio_pin, bool buffered, Callback *cb=NULL) |
void | sample_stop () |
uint8_t | read (MAX30100_REG reg) |
void | write (MAX30100_REG reg, uint8_t wr_data) |
uint16_t | version () |
float | temperature () |
void | mode (MAX30100_MODE mode) |
MAX30100_MODE | mode () |
void | high_res_enable (bool enable) |
bool | high_res_enable () |
void | sample_rate (MAX30100_SR sample_rate) |
MAX30100_SR | sample_rate () |
void | pulse_width (MAX30100_LED_PW pulse_width) |
MAX30100_LED_PW | pulse_width () |
void | current (MAX30100_LED_CURRENT ir, MAX30100_LED_CURRENT r) |
MAX30100_LED_CURRENT | current_ir () |
MAX30100_LED_CURRENT | current_r () |
void | reset () |
void | sleep (bool sleep) |
Data Fields | |
Callback * | _callback |
MAX30100 | ( | int16_t | i2c_bus | ) |
Oximeter and heart-rate sensor constructor
Initialize Oximeter and heart-rate sensor. Note, the I2C address is 0x57.
i2c_bus | Target I2C bus |
std::runtime_error | if sensor initialization fails |
max30100_value sample | ( | ) |
Sample a single set of infrared/red values
Note, all setup (sample rate, LED current, and pulse width must be done prior to calling this sample method.
std::runtime_error | on I2C command failure |
void sample_continuous | ( | int | gpio_pin, |
bool | buffered, | ||
Callback * | cb = NULL |
||
) |
Continuously sample Infrared/Red values.
This method requires a GPIO pin which is used to signal sample/samples ready. The INT * pin is open-drain and requires a pullup resistor. The interrupt pin is not designed to sink large currents, so the pull-up resistor value should be large, such as 4.7k ohm. The RCWL-0530 PCB which this library was designed with had the I2C lines and INT pin pulled up to 1.8v.
Note, all setup (sample rate, mode, LED current, and pulse width must be done prior to calling this sample method.
gpio_pin | GPIO pin for interrupt (input from sensor INT pin) |
buffered | Enable buffered sampling. In buffered sampling mode, the device reads 16 samples at a time. This can help with I2C read timing. buffered == true, enable buffered sampling buffered == false, single-sample mode |
cb | Pointer to instance of Callback class. If parameter is left NULL, a default instance of the Callback class will be used which prints out the IR/R values. |
std::runtime_error | on I2C command failure |
void sample_stop | ( | ) |
Stop continuous sampling. Disable interrupts.
uint8_t read | ( | MAX30100_REG | reg | ) |
Read Oximeter and heart-rate sensor registers
reg | Target register to read |
std::runtime_error | if I2C read command fails |
void write | ( | MAX30100_REG | reg, |
uint8_t | wr_data | ||
) |
Write Oximeter and heart-rate sensor registers
reg | Target register to write |
wr_data | Target data to write |
std::runtime_error | if I2C write command fails |
uint16_t version | ( | ) |
Get sensor version Sensor version is a 2 byte value: upper byte = PART ID lower byte = REVISION ID
example: version() return 0x1105 0x11 = PART ID 0x05 = REVISION
std::runtime_error | on I2C command failure |
float temperature | ( | ) |
Get temperature reading from device
std::runtime_error | on I2C command failure |
void mode | ( | MAX30100_MODE | mode | ) |
Set the sampling mode (none vs red only vs SpO2)
mode | Target sampling mode |
std::runtime_error | on I2C command failure |
MAX30100_MODE mode | ( | ) |
Get the sampling mode
std::runtime_error | on I2C command failure |
void high_res_enable | ( | bool | enable | ) |
Enable or disable high-resolution mode
enable | High-resolution enable true == SpO2 ADC resolution of 16 bit with 1.6ms LED pw |
std::runtime_error | on I2C command failure |
bool high_res_enable | ( | ) |
Get the high-resolution enable bit
std::runtime_error | on I2C command failure |
void sample_rate | ( | MAX30100_SR | sample_rate | ) |
Set the sample rate
sample_rate | Target sample rate |
std::runtime_error | on I2C command failure |
MAX30100_SR sample_rate | ( | ) |
Get the sample rate
std::runtime_error | on I2C command failure |
void pulse_width | ( | MAX30100_LED_PW | pulse_width | ) |
Set the LED pulse width
pulse_width | Target LED pulse width |
std::runtime_error | on I2C command failure |
MAX30100_LED_PW pulse_width | ( | ) |
Get the LED pulse width
std::runtime_error | on I2C command failure |
void current | ( | MAX30100_LED_CURRENT | ir, |
MAX30100_LED_CURRENT | r | ||
) |
Set the current for the infrared and red LEDs
ir | LED current enum |
r | LED current enum |
std::runtime_error | on I2C command failure |
MAX30100_LED_CURRENT current_ir | ( | ) |
Get the infrared LED current
std::runtime_error | on I2C command failure |
MAX30100_LED_CURRENT current_r | ( | ) |
Get the red LED current
std::runtime_error | on I2C command failure |
void reset | ( | ) |
Reset sensor
When the RESET bit is set to one, all configuration, threshold, and data registers are reset to their power-on-state. The only exception is writing both RESET and TEMP_EN bits to one at the same time since temperature data registers 0x16 and 0x17 are not cleared. The RESET bit is cleared automatically back to zero after the reset sequence is completed.
std::runtime_error | on I2C command failure |
void sleep | ( | bool | sleep | ) |
Put device into power-save mode. While in power-save mode, all registers retain their values, and write/read operations function as normal. All interrupts are cleared to zero in this mode.
sleep | Enter/exit power-save mode |
std::runtime_error | on I2C command failure |