0% found this document useful (0 votes)
8 views3 pages

sketch may٠٧a

The document describes code for reading heart rate and oxygen saturation levels from a MAX30100 sensor. It initializes the sensor, sets it to SPO2 and HR mode, and samples data in a loop. Pixel values are drawn on a display based on IR values over time to estimate BPM.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

sketch may٠٧a

The document describes code for reading heart rate and oxygen saturation levels from a MAX30100 sensor. It initializes the sensor, sets it to SPO2 and HR mode, and samples data in a loop. Pixel values are drawn on a display based on IR values over time to estimate BPM.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

/////////

#include <UTFTGLUE.h> //use GLUE class and constructor


UTFTGLUE myGLCD(0,A2,A1,A3,0,A0);
int d;
int m;
int mm;

#include <Wire.h>
#include "MAX30100.h"
unsigned long x;
unsigned long xx;
unsigned long n;
unsigned long nn;
MAX30100 sensor;

unsigned long time1;


unsigned long time2;
unsigned long time;
unsigned long time3;
void setup()
{ randomSeed(analogRead(0));
myGLCD.InitLCD();
myGLCD.setFont(BigFont);
myGLCD.clrScr();

if (!sensor.begin()) {
Serial.print("FAILED: ");

uint8_t partId = sensor.getPartId();


if (partId == 0xff) {
Serial.println("I2C error");
} else {
Serial.print("wrong part ID 0x");
Serial.print(partId, HEX);
Serial.print(" (expected: 0x");
Serial.println(EXPECTED_PART_ID, HEX);
}
// Stop here
for(;;);
} else {
Serial.println("Success");
}

Serial.print("Enabling HR/SPO2 mode..");


sensor.setMode(MAX30100_MODE_SPO2_HR);
Serial.println("done.");

Serial.print("Configuring LEDs biases to 50mA..");


sensor.setLedsCurrent(MAX30100_LED_CURR_50MA, MAX30100_LED_CURR_50MA);
Serial.println("done.");

delay(10);

Serial.print("Lowering the current to 7.6mA..");


sensor.setLedsCurrent(MAX30100_LED_CURR_7_6MA, MAX30100_LED_CURR_7_6MA);
Serial.println("done.");
delay(10);

Serial.print("Shutting down..");
sensor.shutdown();
Serial.println("done.");

delay(10);

Serial.print("Resuming normal operation..");


sensor.resume();
delay(50);
Serial.println("done.");

uint32_t tsTempSampStart = millis();


Serial.print("Sampling die temperature..");
sensor.startTemperatureSampling();
while(!sensor.isTemperatureReady()) {
if (millis() - tsTempSampStart > 1000) {
Serial.println("ERROR: timeout");
// Stop here
for(;;);
}
}

float temperature = sensor.retrieveTemperature();


Serial.print("done, temp=");
Serial.print(temperature);
Serial.println("C");

if (temperature < 5) {
Serial.println("WARNING: Temperature probe reported an odd value");
} else {
Serial.println("All test pass.");
}

Serial.println();
Serial.println("Press any key to go into sampling loop mode");
//while (!Serial.available());
Serial.begin(115200);
sensor.resetFifo();
////////////
// uint16_t ir, red;
//
// sensor.update();
//
// while (sensor.getRawValues(&ir, &red)) {
// // Ser ial.print("IR=");
// if(ir>x){if(ir>xx){x=ir;}}}
//n=ir;
// Serial.println(ir);
// delay(2000);
}

void loop()
{time = millis ( ) ;

if(d==7320){d=0;
myGLCD.clrScr();}
myGLCD.setColor(0,255,255);
myGLCD.drawPixel(d/20,xx-400);
d++;

uint16_t ir, red;

sensor.update();

while (sensor.getRawValues(&ir, &red)) {


// Ser ial.print("IR=");
if(ir>x){if(ir>xx){x=ir;}}
xx=ir;
////////////////////

//int v = map ( ir , 9000 , 15000 , 30000 , 100000 ) ;


Serial.println(ir);
// delay(10);

if (ir<500&&m==0){m=1;
time1=time;
myGLCD.setColor(0, 255, 0);
// myGLCD.setBackColor(0, 0, 255);
//myGLCD.print(xx, CENTER, 200);

myGLCD.printNumI((60/(time3/1000)), CENTER, 225);

//myGLCD.printNumI(time3, CENTER, 225);

}
if (ir>590&&m==1&&ir<600){mm=1;
}

if (ir<500&&mm==1){time2=time;
time3=(time2-time1);
mm=0;
m=0 ;

}
myGLCD.setColor(0, 255, 0);
// myGLCD.setBackColor(0, 0, 255);
myGLCD.print(" ", CENTER, 200);

// myGLCD.printNumI((60/(time3/1000)), CENTER, 225);

//myGLCD.printNumI(time3, CENTER, 225);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy