Package com.diozero.devices.sandpit
Class Max30102
- java.lang.Object
-
- com.diozero.devices.sandpit.Max30102
-
- All Implemented Interfaces:
DeviceInterface
,AutoCloseable
public class Max30102 extends Object implements DeviceInterface
maxim integrated High-sensitivity Pulse Oximeter and Heart-rate Sensor. DatasheetINT IRD RD GND GND SCL SDA VIN INT: Interrupt pin IRD: The IR LED ground of the MAX30102 chip, generally not connected RD: RED LED ground terminal of MAX30102 chip, generally not connected GND: Ground SCL: I2C Clock SDA: I2C Data VIN: The main power input terminal 1.8-5V 3-bit pad: Select the pull-up level of the bus, depending on the pin master voltage, select 1.8v or 3_3v (this terminal contains 3.3V and above)
The active-low interrupt pin pulls low when an interrupt is triggered. The pin is open-drain, meaning it requires a pull-up resistor (min 4.7kOhm). Credit to: https://makersportal.com/blog/2019/6/24/arduino-heart-rate-monitor-using-max30102-and-pulse-oximetry https://github.com/sparkfun/SparkFun_MAX3010x_Sensor_Library https://github.com/doug-burrell/max30102/blob/master/max30102.py
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Max30102.FifoRolloverOnFull
Controls the behaviour of the FIFO when it becomes completely filled with datastatic class
Max30102.LedPulseWidth
static class
Max30102.Mode
static class
Max30102.Sample
static class
Max30102.SampleAveraging
static class
Max30102.SpO2AdcRange
static class
Max30102.SpO2SampleRate
-
Field Summary
Fields Modifier and Type Field Description static int
FIFO_ALMOST_FULL_MAX
static float
LED_MAX_CURRENT_MA
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearFifo()
void
close()
Close this deviceint
getDataPresent()
int
getFifoReadPointer()
int
getFifoWritePointer()
Max30102.LedPulseWidth
getLedPulseWidth()
int
getRevisionId()
Max30102.SampleAveraging
getSampleAveraging()
Queue<Max30102.Sample>
getSampleQueue()
Max30102.SpO2AdcRange
getSpo2AdcRange()
Max30102.SpO2SampleRate
getSpo2SampleRate()
int
pollForData()
Poll the sensor for new data - call regularly.float
readTemperatureCelsius()
void
reset()
void
setup(Max30102.SampleAveraging sampleAveraging, boolean fifoRolloverOnFull, int fifoAlmostFullValue, Max30102.Mode mode, Max30102.SpO2AdcRange spo2AdcRange, Max30102.SpO2SampleRate spo2SampleRate, Max30102.LedPulseWidth ledPulseWidth, float led1CurrentMA, float led2CurrentMA)
Setup the device.void
shutdown()
void
wakeup()
-
-
-
Field Detail
-
FIFO_ALMOST_FULL_MAX
public static final int FIFO_ALMOST_FULL_MAX
- See Also:
- Constant Field Values
-
LED_MAX_CURRENT_MA
public static final float LED_MAX_CURRENT_MA
- See Also:
- Constant Field Values
-
-
Method Detail
-
close
public void close()
Description copied from interface:DeviceInterface
Close this device- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceInterface
-
reset
public void reset()
-
shutdown
public void shutdown()
-
wakeup
public void wakeup()
-
getRevisionId
public int getRevisionId()
-
setup
public void setup(Max30102.SampleAveraging sampleAveraging, boolean fifoRolloverOnFull, int fifoAlmostFullValue, Max30102.Mode mode, Max30102.SpO2AdcRange spo2AdcRange, Max30102.SpO2SampleRate spo2SampleRate, Max30102.LedPulseWidth ledPulseWidth, float led1CurrentMA, float led2CurrentMA)
Setup the device. * Note actual measured current can vary widely due to trimming methodology- Parameters:
sampleAveraging
- number of samples averaged per FIFO samplefifoRolloverOnFull
- whether or not the FIFO rolls over when fullfifoAlmostFullValue
- set the number of data samples remaining in the FIFO when the interrupt is issued (range 0..15). E.g. if set to 0, the interrupt is issued when there are no data samples remaining in the FIFO (all 32 FIFO words have unread data, i.e. the FIFO is full), if set to 15, the interrupt is issued when there are 15 data samples remaining in the FIFO (17 unread)mode
- Operating modespo2AdcRange
- SpO2 ADC rangespo2SampleRate
- SpO2 sample rateledPulseWidth
- LED pulse width (us)led1CurrentMA
- LED-1 pulse amplitude (range 0..51 mA) *led2CurrentMA
- LED-2 pulse amplitude (range 0..51 mA) *
-
getDataPresent
public int getDataPresent()
-
clearFifo
public void clearFifo()
-
getFifoWritePointer
public int getFifoWritePointer()
-
getFifoReadPointer
public int getFifoReadPointer()
-
readTemperatureCelsius
public float readTemperatureCelsius()
-
pollForData
public int pollForData()
Poll the sensor for new data - call regularly. If new data is available, it adds data to the queues- Returns:
- number of new samples obtained
-
getSampleQueue
public Queue<Max30102.Sample> getSampleQueue()
-
getSampleAveraging
public Max30102.SampleAveraging getSampleAveraging()
-
getSpo2AdcRange
public Max30102.SpO2AdcRange getSpo2AdcRange()
-
getSpo2SampleRate
public Max30102.SpO2SampleRate getSpo2SampleRate()
-
getLedPulseWidth
public Max30102.LedPulseWidth getLedPulseWidth()
-
-