How to combine arduino code for max30100 with LM35 and LCD

#include <LiquidCrystal.h>
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

#define REPORTING_PERIOD_MS 1000

PulseOximeter pox;
uint32_t tsLastReport = 0;

void onBeatDetected()
{
Serial.println("Beat!");
}

void setup()
{
Serial.begin(115200);
Serial.print("Initializing pulse oximeter..");
lcd.begin(16,2);
lcd.print("Initializing...");
delay(3000);
lcd.clear();

// 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");
}
 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();
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
Serial.print("Heart rate:");
Serial.print(pox.getHeartRate());
Serial.print("bpm / SpO2:");
Serial.print(pox.getSpO2());
Serial.println("%");

    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("BPM : ");
    lcd.print(pox.getHeartRate());
    
    lcd.setCursor(0,1);
    lcd.print("SpO2: ");
    lcd.print(pox.getSpO2());
    lcd.print("%");

    tsLastReport = millis();
}

}

For temperature coding (LM35),

int val;
int tempPin = 1;

void setup()
{
Serial.begin(9600);
}
void loop()
{
val = analogRead(tempPin);
float mv = ( val/1024.0)5000;
float cel = mv/10;
float farh = (cel
9)/5 + 32;

Serial.print(“TEMPRATURE = “);
Serial.print(cel);
Serial.print(”*C”);
Serial.println();
delay(1000);

/* uncomment this to get temperature in farenhite
Serial.print(“TEMPRATURE = “);
Serial.print(farh);
Serial.print(”*F”);
Serial.println();

*/
}

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.