-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from sparkfun/v1.0.6
v1.0.6 : allow pins to be defined at begin instead of at class instantiation
- Loading branch information
Showing
6 changed files
with
150 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
examples/Example5_define_pins_at_begin/Example5_define_pins_at_begin.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
This example sketch gives you exactly what the SparkFun Pulse Oximiter and | ||
Heart Rate Monitor is designed to do: read heart rate and blood oxygen levels. | ||
Here the reset and mfio pins are defined at begin, instead of when the | ||
SparkFun_Bio_Sensor_Hub is instantiated. This makes it much easier to | ||
instantiate the class using a factory method. | ||
This board requires I-squared-C connections but also connections to the reset | ||
and mfio pins. When using the device keep LIGHT and CONSISTENT pressure on the | ||
sensor. Otherwise you may crush the capillaries in your finger which results | ||
in bad or no results. A summary of the hardware connections are as follows: | ||
SDA -> SDA | ||
SCL -> SCL | ||
RESET -> PIN 4 | ||
MFIO -> PIN 5 | ||
Author: Elias Santistevan | ||
Date: 8/2019 | ||
SparkFun Electronics | ||
If you run into an error code check the following table to help diagnose your | ||
problem: | ||
1 = Unavailable Command | ||
2 = Unavailable Function | ||
3 = Data Format Error | ||
4 = Input Value Error | ||
5 = Try Again | ||
255 = Error Unknown | ||
*/ | ||
|
||
#include <SparkFun_Bio_Sensor_Hub_Library.h> | ||
#include <Wire.h> | ||
|
||
// Reset pin, MFIO pin | ||
int resPin = 4; | ||
int mfioPin = 5; | ||
|
||
// The reset pin and MFIO pin will be defined at begin in this example. | ||
SparkFun_Bio_Sensor_Hub bioHub; | ||
|
||
bioData body; | ||
// ^^^^^^^^^ | ||
// What's this!? This is a type (like int, byte, long) unique to the SparkFun | ||
// Pulse Oximeter and Heart Rate Monitor. Unlike those other types it holds | ||
// specific information on your heartrate and blood oxygen levels. BioData is | ||
// actually a specific kind of type, known as a "struct". | ||
// You can choose another variable name other than "body", like "blood", or | ||
// "readings", but I chose "body". Using this "body" varible in the | ||
// following way gives us access to the following data: | ||
// body.heartrate - Heartrate | ||
// body.confidence - Confidence in the heartrate value | ||
// body.oxygen - Blood oxygen level | ||
// body.status - Has a finger been sensed? | ||
|
||
|
||
void setup(){ | ||
|
||
Serial.begin(115200); | ||
|
||
Wire.begin(); | ||
int result = bioHub.begin(Wire, resPin, mfioPin); // Define the pins here | ||
if (result == 0) // Zero errors! | ||
Serial.println("Sensor started!"); | ||
else | ||
Serial.println("Could not communicate with the sensor!"); | ||
|
||
Serial.println("Configuring Sensor...."); | ||
int error = bioHub.configBpm(MODE_ONE); // Configuring just the BPM settings. | ||
if(error == 0){ // Zero errors! | ||
Serial.println("Sensor configured."); | ||
} | ||
else { | ||
Serial.println("Error configuring sensor."); | ||
Serial.print("Error: "); | ||
Serial.println(error); | ||
} | ||
|
||
// Data lags a bit behind the sensor, if you're finger is on the sensor when | ||
// it's being configured this delay will give some time for the data to catch | ||
// up. | ||
Serial.println("Loading up the buffer with data...."); | ||
delay(4000); | ||
|
||
} | ||
|
||
void loop(){ | ||
|
||
// Information from the readBpm function will be saved to our "body" | ||
// variable. | ||
body = bioHub.readBpm(); | ||
Serial.print("Heartrate: "); | ||
Serial.println(body.heartRate); | ||
Serial.print("Confidence: "); | ||
Serial.println(body.confidence); | ||
Serial.print("Oxygen: "); | ||
Serial.println(body.oxygen); | ||
Serial.print("Status: "); | ||
Serial.println(body.status); | ||
// Slow it down or your heart rate will go up trying to keep up | ||
// with the flow of numbers | ||
delay(250); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=SparkFun Bio Sensor Hub Library | ||
version=1.0.5 | ||
version=1.0.6 | ||
author=Elias Santistevan <[email protected]> | ||
maintainer=SparkFun Electronics <sparkfun.com> | ||
sentence=Library for the MAX32664 Bio Metric Hub IC | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters