MAX30105 Particle and Pulse Ox Sensor Hookup Guide
Example 2 - Presence Sensing
Open the Example2 Presence Sensing sketch, and load it onto your RedBoard or Uno.
This example takes a handful of readings during setup and averages them together. It uses this average as a baseline. If the sensor detects a significant change from the average, then “Something is there!” is printed. This is useful when you need to detect if a ball drops through a channel or other photo-gate situations. It's also handy for testing the range at which the sensor can detect something.
language:c
//Setup to sense up to 18 inches, max LED brightness
byte ledBrightness = 0xFF; //Options: 0=Off to 255=50mA
byte sampleAverage = 4; //Options: 1, 2, 4, 8, 16, 32
byte ledMode = 2; //Options: 1 = Red only, 2 = Red + IR, 3 = Red + IR + Green
byte sampleRate = 400; //Options: 50, 100, 200, 400, 800, 1000, 1600, 3200
int pulseWidth = 411; //Options: 69, 118, 215, 411
int adcRange = 2048; //Options: 2048, 4096, 8192, 16384
particleSensor.setup(ledBrightness, sampleAverage, ledMode, sampleRate, pulseWidth, adcRange); //Configure sensor with these settings
During setup this code initializes the sensor. There are many different options and configurations for the MAX30105. You can define as many or as few as you'd like. You can also skip them all:
language:c
particleSensor.setup(); //Configure sensor with default settings
The sensor will be configured with the default settings. The default settings work for most applications.