1 arduino nano v3
3 résistances 4.7 kO
1 écran 0.96″ I2C IIC Serial 128X64 128*64 Blue OLED


MAX30100 MAX30102 Heart Rate Breakout Sensor Blood Oxygen Transducer for Arduino

Installer les libs :
[root@10-83-102-17 SSD1306Ascii]# more library.properties
name=SSD1306Ascii
version=1.3.0
author=Bill Greiman fat16lib@sbcglobal.net
maintainer=Bill Greiman fat16lib@sbcglobal.net
sentence=Text display on small momochrome OLED modules.
paragraph=A basic SSD1306 text only library optimized for minimum memory usage.
category=Display
url=https://github.com/greiman/SSD1306Ascii
architectures=*
[root@10-83-102-17 libraries]# more MAX30100lib/library.properties
name=MAX30100lib
version=1.2.1
author=OXullo Intersecans x@brainrapers.org
maintainer=OXullo Intersecans x@brainrapers.org
sentence=Maxim-IC MAX30100 heart-rate sensor driver and pulse-oximetry components
paragraph=This library exposes most of the features of the MAX30100 and offers a modular approach to calculate pulse rate and SpO2
category=Sensors
url=https://github.com/oxullo/Arduino-MAX30100
architectures=*
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"
#define REPORTING_PERIOD_MS 1000
// PulseOximeter is the higher level interface to the sensor
// it offers:
// * beat detection reporting
// * heart rate calculation
// * SpO2 (oxidation level) calculation
PulseOximeter pox;
SSD1306AsciiWire oled;
uint32_t tsLastReport = 0;
// Callback (registered below) fired when a pulse is detected
void onBeatDetected()
{
Serial.println("Beat!");
}
void setup()
{
Serial.begin(115200);
oled.begin(&Adafruit128x64, 0x3C);
Serial.println("ok2");
oled.setFont(Arial14);
Serial.print("Initializing pulse oximeter..");
// Initialize the PulseOximeter instance
// Failures are generally due to an improper I2C wiring, missing power supply
// or wrong target chip
if (!pox.begin()) {
Serial.println("FAILED");
for(;;);
} else {
Serial.println("SUCCESS");
}
// The default current for the IR LED is 50mA and it could be changed
// by uncommenting the following line. Check MAX30100_Registers.h for all the
// available options.
pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
// Register a callback for the beat detection
pox.setOnBeatDetectedCallback(onBeatDetected);
}
void loop()
{
// Make sure to call update as fast as possible
pox.update();
// Asynchronously dump heart rate and oxidation levels to the serial
// For both, a value of 0 means "invalid"
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
Serial.print("Heart rate:");
Serial.print(pox.getHeartRate());
Serial.print("bpm / SpO2:");
Serial.print(pox.getSpO2());
Serial.println("%");
printToScreen();
tsLastReport = millis();
}
}
void printToScreen() {
oled.clear();
oled.setCursor(0,0);
oled.print(F("HR: ")); oled.println(pox.getHeartRate(), DEC);
oled.print(F("SPO2: ")); oled.println(pox.getSpO2(), DEC);
}