This module contains the driver for MAXIM MAX30101 pulse oximetry and heart-rate monitor module. The MAX30101 is capable of direct I2C communication and can be set on 3 different operating mode (datasheet).
Creates an intance of the MAX30101 class.
- i2cdrv – I2C Bus used ‘( I2C0, … )’
- addr – Slave address, default 0x75
- clk – Clock speed, default 400kHz.
from maxim.max30101 import max30101 ... m301 = max30101.MAX30101(I2C0) m301.start() m301.init() data = m301.read_raw_samples(6)
init(mode = 'spo2',adc_range = 3,sample_rate = 50,pulse_width = 411,led_current = [255,255,0,0],proximity_thrs = 0,slot_multi = [0,0,0,0])
Initialize the MAX30101. Default paramter values enable
"spo2" - without proximity - mode with: maximum ADC range, sampling rate of 50 Hz, LED pulse width of 411us and maximum pulse amplitude for both red and IR LEDs.
- mode – set the operating state of the MAX30101, default mode is
- adc_range – sets the SpO2 sensor ADC’s full-scale range, maximum range by default.
- sample_rate – sets the sampling rate, default is 50 Hz.
- pulse_width – LEDs pulse width in microsecond, default value is 411.
- led_current – sets red, IR, green and IR for proximity mode LEDs pulse amplitude, by default only red and IR red are set to maximum value.
- proximity_thrs – sets the threshold for the proximity mode.
- slot_multi – configuration parameter for
For details on available values for all the parameters see
The MAX30101 stores the digital output data in a 32-deep circular FIFO within the IC. The sample size depends on the number of LED configured as active. As each led signal is stored as a 3-byte data, the FIFO width can be 3, 6, 9 or 12 bytes in size.
To reduce the amount of data throughput,
n adjacent samples (in each individual channel) can be averaged and decimated on the chip by using this method. Accepted values for
n are: 1,2,4,8,16 and 32.
set_fifo_rollover(ro = True)
This method controls the behavior of the FIFO when the FIFO becomes completely filled with data. If
True, the FIFO Address rolls over to zero and the FIFO continues to fill with new data. If
False, then the FIFO is not updated until FIFO is read or the FIFO WRITE/READ pointer positions are changed.
This method sets the trigger for the
"full" interrupt. The interrupt triggers when there are
n empty spaces left in FIFO.
Return a nbyte-long bytearray containing raw data read from the FIFO.
This method set to zero the FIFO read and write pointers and the overflow counter.
Set bit on enable interrupt registers corresponding to the selected source. ‘sources’ must be a list including one or more available sources. Available values for ‘sources’ are:
hrmode, this interrupt triggers when FIFO has a certain number of free spaces remaining.
hrmode, this interrupt triggers when there is a new sample in the data FIFO.
"alc": this interrupt triggers when the ambient light cancellation function of the SpO2/HR photodiode has reached its maximum limit, and therefore, ambient light is affecting the output of the ADC.
"prox": the proximity interrupt is triggered when the proximity threshold is reached, and SpO2/HR mode has begun.
"temp": when an internal die temperature conversion is finished, this interrupt is triggered so the processor can read the temperature data registers.
This method needs to read which interrupt is triggered when more then one is enabled and returns a list containing triggered interrupts.
interrupt defines are shown in method above; this function can return “pwr” interrupt (triggered on every power-up) that is enabled by default and cannot be disabled.
Disable all interrupts.
Put the part into a 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.
Wake up the MAX30101 component.
All configuration, threshold, and data registers are reset to their power-on-state through a power-on reset.
Set the operating mode of the MAX30101. Default paramter values are the same of
mode : set the operating state of the MAX30101. Available values are:
"hr": Heart Rate mode - only red LED is used for conversion.
"spo2": SpO2 mode - red and IR LEDs are used for conversion.
"multi": Multi-LED mode - green, red and/or IR LEDs can be used for conversion.
- adc_range : sets the SpO2 sensor ADC’s full-scale range as shown in the table below.
|adc_range||LSB size (pA)||Full Scale (nA)|
sample_rate : sets the SpO2 effective sample rate. One sample consists of one IR pulse/conversion and one RED pulse/conversion. The sample rate and pulse width are related in that the sample rate sets an upper bound on the pulse width time. If the user selects a sample rate that is too high for the selected pulse_width setting, the highest possible sample rate is programmed instead. Available sampling rate values are: 50, 100, 200, 400, 800, 1000, 1600, 3200.
pulse_width : set the LED pulse width and indirectly sets the ADC resolution. All LEDs (IR, red and green) have the same pulse width.
|pulse_width||Pulse width (us)||ADC Resolution (bits)|
- led_current : sets the pulse amplitude for the LEDs. led_current = [red, ir, green, pilot]. The purpose of pilot is to set the LED power during the proximity mode, as well as in
|red, ir, green or pilot||Led Current (mA)|
proximity_thrs: sets the IR ADC count that will trigger the beginning of
"spo2"mode and, if enabled, the prox interrupt. The threshold is defined as the 8 MSBs of the ADC count. For example, if proximity_thrs = 1, then an ADC value of 1023 (decimal) or higher triggers the prox interrupt. If proximity_thrs = 255, then only a saturated ADC triggers the interrupt.
"multi"mode, each sample is split into up to four time slots, slot1 through slot4. slot_multi = [slot1, slot2, slot3, slot4]. These method control which LED is active with which amplitude in each time slot, making for a very flexible configuration. The slots should be enabled in order (i.e., slot1 should not be disabled if slot2 or slot3 are enabled).
|slotX||Active Led||Led Pulse Amplitude (led_current value)|
Initiates a single temperature reading from the temperature sensor.
Returns a float representing the last temperature reading in Celsius.
Returns the Part ID of the component.
Returns the Revision ID of the component.