upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions | Data Fields

API for the Pulse oximeter and heart-rate sensor. More...

Detailed Description

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

max30100.png
// Instantiate a MAX30100 instance using i2c bus 0
upm::MAX30100 sensor(0);
// Create an instance of the Callback class
mycallback cb;
// Read the temperature and version
std::cout << "Temperature: " << sensor.temperature() << " C" << std::endl;
std::cout << "Version: " << sensor.version() << std::endl;
// Set high-res (50 Hz, 16-bit)
sensor.high_res_enable(true);
// Set to sample SpO2
sensor.mode(MAX30100_MODE_SPO2_EN);
// Read continuously, stepping up the LED current every second,
// us GPIO 0 as the interrupt pin
sensor.sample_continuous(0, false, &cb);
for (int i = MAX30100_LED_CURRENT_0_0_MA; i <= MAX30100_LED_CURRENT_50_0_MA && shouldRun; i++) {
// Toggle the LED current
std::cout << "Setting LED current = " << i << std::endl;
sensor.current((MAX30100_LED_CURRENT) i, (MAX30100_LED_CURRENT) i);
upm_delay(1);
}
// Read individual samples
for (int i = 0; i < 10; i++) {
max30100_value val = sensor.sample();
std::cout << "Single value IR: " << val.IR << " R: " << val.R << std::endl;
}

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
 

Constructor & Destructor Documentation

MAX30100 ( int16_t  i2c_bus)

Oximeter and heart-rate sensor constructor

Initialize Oximeter and heart-rate sensor. Note, the I2C address is 0x57.

Parameters
i2c_busTarget I2C bus
Returns
sensor context pointer
Exceptions
std::runtime_errorif sensor initialization fails

Here is the call graph for this function:

virtual ~MAX30100 ( )
inlinevirtual

MAX30100 destructor

Member Function Documentation

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.

Returns
One IR/R sample
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
gpio_pinGPIO pin for interrupt (input from sensor INT pin)
bufferedEnable 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
cbPointer 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.
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

void sample_stop ( )

Stop continuous sampling. Disable interrupts.

Here is the call graph for this function:

uint8_t read ( MAX30100_REG  reg)

Read Oximeter and heart-rate sensor registers

Parameters
regTarget register to read
Returns
Data returned from sensor
Exceptions
std::runtime_errorif I2C read command fails

Here is the call graph for this function:

void write ( MAX30100_REG  reg,
uint8_t  wr_data 
)

Write Oximeter and heart-rate sensor registers

Parameters
regTarget register to write
wr_dataTarget data to write
Exceptions
std::runtime_errorif I2C write command fails

Here is the call graph for this function:

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

Returns
Sensor version
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

float temperature ( )

Get temperature reading from device

Returns
rd_data Temperature in degrees Celsius
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

void mode ( MAX30100_MODE  mode)

Set the sampling mode (none vs red only vs SpO2)

Parameters
modeTarget sampling mode
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

MAX30100_MODE mode ( )

Get the sampling mode

Returns
Current sampling mode
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

void high_res_enable ( bool  enable)

Enable or disable high-resolution mode

Parameters
enableHigh-resolution enable true == SpO2 ADC resolution of 16 bit with 1.6ms LED pw
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

bool high_res_enable ( )

Get the high-resolution enable bit

Returns
Current high-resolution bit value
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

void sample_rate ( MAX30100_SR  sample_rate)

Set the sample rate

Parameters
sample_rateTarget sample rate
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

MAX30100_SR sample_rate ( )

Get the sample rate

Returns
Current sample rate
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

void pulse_width ( MAX30100_LED_PW  pulse_width)

Set the LED pulse width

Parameters
pulse_widthTarget LED pulse width
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

MAX30100_LED_PW pulse_width ( )

Get the LED pulse width

Returns
Current LED pulse width
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

void current ( MAX30100_LED_CURRENT  ir,
MAX30100_LED_CURRENT  r 
)

Set the current for the infrared and red LEDs

Parameters
irLED current enum
rLED current enum
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

MAX30100_LED_CURRENT current_ir ( )

Get the infrared LED current

Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

MAX30100_LED_CURRENT current_r ( )

Get the red LED current

Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

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.

Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

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.

Parameters
sleepEnter/exit power-save mode
Exceptions
std::runtime_erroron I2C command failure

Here is the call graph for this function:

Collaboration diagram for MAX30100:
Collaboration graph
[legend]

The documentation for this class was generated from the following files: