Skip to content

Commit 3a1b51f

Browse files
committed
Merge branch 'master' of github.com:opensensinglab/max30105
2 parents 40f2087 + f62a957 commit 3a1b51f

File tree

14 files changed

+3515
-0
lines changed

14 files changed

+3515
-0
lines changed

CC-BY-SA.TXT

+425
Large diffs are not rendered by default.

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MAX30105 Air Particle Sensor Driver and Breakout Board
2+
======
3+
4+
Work-in-progress. <br>
5+
This is a driver and breakout board to explore the new MAX30105 Air Particle Sensor. <br>
6+
7+
8+
# Open Source
9+
10+
This project is open source software and hardware, and is released under various open licenses.
11+
12+
# Disclaimer
13+
14+
**DISCLAIMER OF WARRANTIES AND LIMITATION OF LIABILITY.**
15+
16+
UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
17+
18+
TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
19+
20+
THE DISCLAIMER OF WARRANTIES AND LIMITATION OF LIABILITY PROVIDED ABOVE SHALL BE INTERPRETED IN A MANNER THAT, TO THE EXTENT POSSIBLE, MOST CLOSELY APPROXIMATES AN ABSOLUTE DISCLAIMER AND WAIVER OF ALL LIABILITY.
21+

breakout/board_bottom.png

40.1 KB
Loading

breakout/board_top.png

90 KB
Loading

breakout/breakout_picture.jpg

176 KB
Loading

breakout/max30105_breakout.brd

+678
Large diffs are not rendered by default.

breakout/max30105_breakout.sch

+1,200
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
MAX30105 Breakout: Output all the raw Red/IR/Green readings
3+
By: Nathan Seidle @ SparkFun Electronics
4+
Date: October 2nd, 2016
5+
https://github.com/sparkfun/MAX30105_Breakout
6+
7+
Outputs all Red/IR/Green values at 25Hz.
8+
9+
*/
10+
11+
#include <Wire.h>
12+
#include "MAX30105.h"
13+
14+
MAX30105 particleSensor;
15+
16+
long startTime;
17+
long samplesTaken = 0; //Counter for calculating the Hz or read rate
18+
19+
void setup()
20+
{
21+
Serial.begin(115200);
22+
Serial.println("Initializing...");
23+
24+
// Initialize sensor
25+
if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port, 400kHz speed
26+
{
27+
Serial.println("MAX30105 was not found. Please check wiring/power. ");
28+
while (1);
29+
}
30+
31+
//particleSensor.setup(); //Configure sensor. Use 6.4mA for LED drive
32+
particleSensor.setup(0x7F); //Configure sensor. Use 25mA for LED drive
33+
34+
startTime = millis();
35+
}
36+
37+
void loop()
38+
{
39+
particleSensor.check(); //Check the sensor, read up to 3 samples
40+
41+
while (particleSensor.available()) //do we have new data?
42+
{
43+
samplesTaken++;
44+
45+
Serial.print(" R[");
46+
Serial.print(particleSensor.getRed());
47+
Serial.print("] IR[");
48+
Serial.print(particleSensor.getIR());
49+
Serial.print("] G[");
50+
Serial.print(particleSensor.getGreen());
51+
Serial.print("] Hz[");
52+
Serial.print((float)samplesTaken / ((millis() - startTime) / 1000.0), 2);
53+
Serial.print("]");
54+
55+
Serial.println();
56+
57+
particleSensor.nextSample(); //We're finished with this sample so move to next sample
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
MAX30105 Breakout: Take IR reading to sense presence
3+
By: Nathan Seidle @ SparkFun Electronics
4+
Date: October 2nd, 2016
5+
https://github.com/sparkfun/MAX30105_Breakout
6+
7+
This takes an average reading at power up and if the reading changes more than 100
8+
then print 'Something is there!'.
9+
10+
*/
11+
12+
#include <Wire.h>
13+
#include "MAX30105.h"
14+
15+
MAX30105 particleSensor;
16+
17+
long startTime;
18+
long samplesTaken = 0; //Counter for calculating the Hz or read rate
19+
20+
long unblockedValue; //Average IR at power up
21+
22+
void setup()
23+
{
24+
Serial.begin(115200);
25+
Serial.println("Initializing...");
26+
27+
// Initialize sensor
28+
if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port, 400kHz speed
29+
{
30+
Serial.println("MAX30105 was not found. Please check wiring/power. ");
31+
while (1);
32+
}
33+
34+
particleSensor.setup(0x7F); //Configure sensor. Use 25mA for LED drive
35+
particleSensor.setPulseAmplitudeRed(0); //Turn off Red LED
36+
particleSensor.setPulseAmplitudeGreen(0); //Turn off Green LED
37+
38+
startTime = millis();
39+
40+
//Take an average of IR readings at power up
41+
unblockedValue = 0;
42+
for (byte x = 0 ; x < 32 ; x++)
43+
{
44+
//Wait for new readings to come in
45+
while (particleSensor.available() == false)
46+
{
47+
particleSensor.check(); //Check the sensor, read up to 3 samples
48+
}
49+
50+
unblockedValue += particleSensor.getIR(); //Read the IR value
51+
particleSensor.nextSample(); //We're finished with this sample so move to next sample
52+
}
53+
unblockedValue /= 32;
54+
55+
}
56+
57+
void loop()
58+
{
59+
particleSensor.check(); //Check the sensor, read up to 3 samples
60+
61+
while (particleSensor.available()) //do we have new data?
62+
{
63+
samplesTaken++;
64+
65+
Serial.print("IR[");
66+
Serial.print(particleSensor.getIR());
67+
Serial.print("] Hz[");
68+
Serial.print((float)samplesTaken / ((millis() - startTime) / 1000.0), 2);
69+
Serial.print("]");
70+
71+
long currentDelta = particleSensor.getIR() - unblockedValue;
72+
73+
Serial.print(" CD[");
74+
Serial.print(currentDelta);
75+
Serial.print("]");
76+
77+
if (currentDelta > (long)100)
78+
{
79+
Serial.print(" Something is there!");
80+
}
81+
82+
Serial.println();
83+
84+
particleSensor.nextSample(); //We're finished with this sample so move to next sample
85+
}
86+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
Optical Heart Rate Detection (PBA Algorithm) using the MAX30105 Breakout
3+
By: Nathan Seidle @ SparkFun Electronics
4+
Date: October 2nd, 2016
5+
https://github.com/sparkfun/MAX30105_Breakout
6+
7+
This is a demo to show the reading of heart rate or beats per minute (BPM) using
8+
a Penpheral Beat Amplitude (PBA) algorithm.
9+
10+
11+
*/
12+
13+
#include <Wire.h>
14+
#include "MAX30105.h"
15+
16+
#include "heartRate.h"
17+
18+
MAX30105 particleSensor;
19+
20+
const byte RATE_SIZE = 4; //Increase this for more averaging. 4 is good.
21+
byte rates[RATE_SIZE]; //Array of heart rates
22+
byte rateSpot = 0;
23+
long lastBeat = 0; //Time at which the last beat occurred
24+
25+
void setup()
26+
{
27+
Serial.begin(115200);
28+
Serial.println("Initializing...");
29+
30+
// Initialize sensor
31+
if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port, 400kHz speed
32+
{
33+
Serial.println("MAX30105 was not found. Please check wiring/power. ");
34+
while (1);
35+
}
36+
Serial.println("Place your index finger on the sensor with steady pressure.");
37+
38+
particleSensor.setup(0x7F); //Configure sensor. Use 25mA for LED drive
39+
particleSensor.setPulseAmplitudeRed(0x0A); //Turn Red LED to low
40+
particleSensor.setPulseAmplitudeGreen(0); //Turn off Green LED
41+
}
42+
43+
void loop()
44+
{
45+
particleSensor.check(); //Check the sensor often
46+
47+
if (particleSensor.available()) //do we have new data?
48+
{
49+
if (checkForBeat(particleSensor.getIR()) == true)
50+
{
51+
//We sensed a beat!
52+
53+
long delta = millis() - lastBeat;
54+
lastBeat = millis();
55+
56+
float beatsPerMinute = 60 / (delta / 1000.0);
57+
58+
if (beatsPerMinute < 255 && beatsPerMinute > 20)
59+
{
60+
Serial.print("BPM: ");
61+
Serial.print(beatsPerMinute);
62+
63+
rates[rateSpot++] = (byte)beatsPerMinute; //Store this reading in the array
64+
rateSpot %= RATE_SIZE; //Wrap variable
65+
66+
//Take average of readings
67+
int beatAvg = 0;
68+
for(byte x = 0 ; x < RATE_SIZE ; x++)
69+
beatAvg += rates[x];
70+
beatAvg /= RATE_SIZE;
71+
72+
Serial.print(" Avg BPM: ");
73+
Serial.println(beatAvg);
74+
}
75+
else
76+
{
77+
Serial.println("Getting reading");
78+
}
79+
}
80+
81+
particleSensor.nextSample(); //We're finished with this sample so move to next sample
82+
83+
}
84+
}
85+
86+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
MAX30105 Breakout: Output all the raw Red/IR/Green readings, check INT pin and interrupt register
3+
By: Nathan Seidle @ SparkFun Electronics
4+
Date: October 2nd, 2016
5+
https://github.com/sparkfun/MAX30105_Breakout
6+
7+
Outputs all Red/IR/Green values as fast as possible
8+
Checks the interrupt pin to see if an interrupt occurred
9+
Checks the interrupt register to see if a bit was set
10+
*/
11+
12+
#include <Wire.h>
13+
#include "MAX30105.h"
14+
15+
MAX30105 particleSensor;
16+
17+
long startTime;
18+
long samplesTaken = 0; //Counter for calculating the Hz or read rate
19+
20+
byte interruptPin = 3; //Connect INT pin on breakout board to pin 3
21+
22+
void setup()
23+
{
24+
pinMode(interruptPin, INPUT);
25+
26+
Serial.begin(115200);
27+
Serial.println("Initializing...");
28+
29+
// Initialize sensor
30+
if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port, 400kHz speed
31+
{
32+
Serial.println("MAX30105 was not found. Please check wiring/power. ");
33+
while (1);
34+
}
35+
36+
//25mA for LED drive, no sample average, 3 LED mode, sample rate, Pulsewidth of 69, 15-bit
37+
//particleSensor.setup(0x7F, 1, 3, 200, 69); //At 200Hz serial can keep up, no interrupts
38+
particleSensor.setup(0x7F, 1, 3, 400, 69); //At 400Hz serial can't keep up and we get interrupts
39+
40+
particleSensor.enableAFULL(); //Enable the almost full interrupt (default is 32 samples)
41+
42+
particleSensor.setFIFOAlmostFull(3); //Set almost full int to fire at 29 samples
43+
44+
startTime = millis();
45+
}
46+
47+
void loop()
48+
{
49+
particleSensor.check(); //Check the sensor, read up to 3 samples
50+
51+
while (particleSensor.available()) //do we have new data?
52+
{
53+
samplesTaken++;
54+
55+
Serial.print(" R[");
56+
Serial.print(particleSensor.getRed());
57+
Serial.print("] IR[");
58+
Serial.print(particleSensor.getIR());
59+
Serial.print("] G[");
60+
Serial.print(particleSensor.getGreen());
61+
Serial.print("] Hz[");
62+
Serial.print((float)samplesTaken / ((millis() - startTime) / 1000.0), 2);
63+
Serial.print("]");
64+
65+
if (digitalRead(interruptPin) == LOW) //Hardware way of reading interrupts
66+
{
67+
Serial.print(" INT!");
68+
}
69+
70+
byte flags = particleSensor.getINT1(); //Software way of reading interrupts
71+
if (flags)
72+
{
73+
Serial.print(" I[");
74+
Serial.print(flags, BIN);
75+
Serial.print("]");
76+
}
77+
78+
Serial.println();
79+
80+
particleSensor.nextSample(); //We're finished with this sample so move to next sample
81+
}
82+
}

keywords.txt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#######################################
2+
# Syntax Coloring Map
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
MAX30105 KEYWORD1
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
15+
begin KEYWORD2
16+
setup KEYWORD2
17+
available KEYWORD2
18+
getRed KEYWORD2
19+
getIR KEYWORD2
20+
getGreen KEYWORD2
21+
readTemperature KEYWORD2
22+
readTemperatureF KEYWORD2
23+
24+
#######################################
25+
# Constants (LITERAL1)
26+
#######################################

0 commit comments

Comments
 (0)