Hi All,
I am trying to incorporate a MLX96014 infrared temp sensor and MAX30100 pulse oximeter into a project using the arduino MKR1000. I want to take the readings from the sensors and display them on my phone using the blynk app both sets of test sketches for each sensor works perfect individually, but wen i try to incorporate them into the same sketch i am only getting a reading from the temp sensor. I have exhausted all avenues and would appreciate any guidance as the online information is limited. code attached and pasted any help would be greatlyappreciated
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#include <Adafruit_MLX90614.h>
#define REPORTING_PERIOD_MS 1000
////////////////////////////////////////////////////
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
double temp_amb;
double temp_obj;
double calibration = 2.36;
////////////////////////////////////////////////////
PulseOximeter pox;
float BPM, SpO2;
uint32_t tsLastReport = 0;
void onBeatDetected()
{
Serial.println("Beat Detected!");
}
void setup()
{
Serial.begin(115200);
pinMode(1, OUTPUT);
Serial.print("Initializing Pulse Oximeter..");
if (!pox.begin())
{
Serial.println("FAILED");
for(;;);
}
else
{
Serial.println("SUCCESS");
pox.setOnBeatDetectedCallback(onBeatDetected);
}
// The default current for the IR LED is 50mA and it could be changed by uncommenting the following line.
pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
mlx.begin(); //Initialize MLX90614
delay(2000);
Serial.println("Temperature Sensor MLX90614");
}
void loop()
{
pox.update();
//Blynk.run();
BPM = pox.getHeartRate();
SpO2 = pox.getSpO2();
if (millis() - tsLastReport > REPORTING_PERIOD_MS)
{
Serial.print("\nHeart rate:");
Serial.print(BPM);
Serial.print("\nSpO2:");
Serial.print(SpO2);
Serial.println(" %");
tsLastReport = millis();
}
temp_amb = mlx.readAmbientTempC();
temp_obj = mlx.readObjectTempC();
delay(2000);
Serial.print("\nRoom Temp = ");
Serial.println(temp_amb);
Serial.print("Object temp = ");
Serial.println(temp_obj);
}
Heart_rate_and_temp_sensor_i2c.ino (1.8 KB)